" + cmd;
if (isSucceed) data += "
";
else data += "
";
data += answer + "
" + content + "
";
this._print(data);
this.scroll_down();
},
scroll_down: function () {
this.contentBox["scrollTop"] = this.contentBox["scrollHeight"];
return;
},
commands: function (msg) {
switch (msg) {
case "clean":
this._clean();
return true;
case "list":
let list = "";
var players = world.players;
for (var i = 0; i < players.length; i++) {
var player = players[i];
if (player.alive) {
list += player.nickname.replaceAll("<", "< ") + '
#' + i + "\n";
}
}
this.write_command("list", 1, "List all connected players", list);
return true;
case "weapon-list":
this.write_command("Weapons", 1, "List all weapons in the game", this.create_array(["sword_wood", "sword", "sword_gold", "sword_diamond", "sword_amethyst", "sword_reidite", "dragon_sword", "lava_sword", "cursed_sword", "sword_pirate", "wood_spear", "spear", "gold_spear", "diamond_spear", "amethyst_spear", "reidite_spear", "dragon_spear", "lava_spear", "crab_spear", "wood_bow", "wood_arrow"]));
return true;
case "tool-list":
this.write_command("Tools", 1, "List all tools in the game", this.create_array(["pick_wood", "pick", "pick_gold", "pick_diamond", "pick_amethyst", "pick_reidite", "hammer", "hammer_gold", "hammer_diamond", "hammer_amethyst", "hammer_reidite", "super_hammer", "shovel", "shovel_gold", "shovel_diamond", "shovel_amethyst", "shovel_reidite", "pitchfork", "pitchfork2", "spanner", "book"]));
return true;
case "survival-list":
this.write_command("Survival Items", 1, "List all survival items in the game", this.create_array(["fire", "workbench", "bandage", "big_fire", "furnace", "paper", "blue_cord", "lock", "lockpick", "totem", "resurrection", "bridge", "bottle_full", "bottle_empty", "watering_can", "watering_can_full", "windmill", "plot", "bread_oven", "chest", "bucket_empty", "bucket_full", "well", "roof", "bed", "boat", "sled", "boar", "saddle", "emerald_machine", "extractor_stone", "extractor_gold", "extractor_diamond", "extractor_amethyst", "extractor_reidite_button"]));
return true;
case "resource-list":
this.write_command("Resources", 1, "List all resources in the game", this.create_array(["wood", "stone", "gold", "diamond", "amethyst", "reidite", "fur", "fur_wolf", "fur_winter", "cord", "scales", "penguin_feather", "flame", "sand", "ground", "ice", "dragon_heart", "lava_heart", "kraken_skin", "special_fur", "special_fur_2", "gemme_green", "gemme_orange", "gemme_blue", "dragon_cube", "dragon_orb", "lava_cube", "lava_orb", "fur_boar", "pitchfork_part", "pilot_glasses", "fur_mammoth"]));
return true;
case "food-list":
this.write_command("Food", 1, "List all food in the game", this.create_array(["plant", "seed", "meat", "cooked_meat", "flour", "wheat_seed", "cookies", "wild_wheat", "cake", "fish", "cooked_fish", "bread", "sandwich", "pumpkin_seed", "pumpkin", "garlic_seed", "garlic", "thornbush_seed", "thornbush", "crab_stick", "claw", "carrot_seed", "carrot", "tomato_seed", "tomato", "watermelon_seed", "watermelon", "aloe_vera_seed", "aloe_vera", "cactus"]));
return true;
case "hat-list":
this.write_command("Hats", 1, "List all hats in the game", this.create_array(["earmuffs", "coat", "scarf", "fur_hat", "warm_protection", "warm_protection2", "warm_protection3", "explorer_hat", "pirate_hat", "wood_helmet", "stone_helmet", "gold_helmet", "diamond_helmet", "amethyst_helmet", "reidite_helmet", "dragon_helmet", "lava_helmet", "crab_helmet", "diving_mask", "super_diving_suit", "crown_green", "crown_orange", "crown_blue", "hood", "peasant", "winter_hood", "winter_peasant", "bag", "turban1", "turban2", "pilot_hat"]));
return true;
case "building-list":
this.write_command("Buildings", 1, "List all buildings in the game", this.create_array(["wall", "stone_wall", "gold_wall", "diamond_wall", "amethyst_wall", "reidite_wall", "spike", "stone_spike", "gold_spike", "diamond_spike", "amethyst_spike", "reidite_spike", "wood_door", "stone_door", "gold_door", "diamond_door", "amethyst_door", "reidite_door", "wood_spike_door", "stone_spike_door", "gold_spike_door", "diamond_spike_door", "amethyst_spike_door", "reidite_spike_door"]));
return true;
case "biome-list":
this.write_command("Biomes list", 1, "List all available biomes in the game", this.create_array(["forest", "winter", "lava", "sea", "beach", "island", "dragon"]));
return true;
case "help-config":
this.write_command("Help Configuration", 1, "Learn how to build your customized map", '
To get the current map configuration, and modify it, copy the result of get-config in a text file and change every parameter you want.
To modify the settings, change a number to another with
set-configTo modify the map, modify "important" section (at the end)
The minimum size of the map is 50x50.
"custom_map" is used to change the biomes and is written like this :
"custom_map":[["biome",width,height],...,["biome",width,height]]
Biomes are
"forest",
"lava",
"winter", and
"dragon".');
return true;
case "pos":
let p = world.fast_units[user.id];
this.write_command("pos", 1, "Your position is " + window.Math.floor(p.x / 100) + ":" + window.Math.floor(p.y / 100));
return true;
case "help-admin":
this.write_command(
"help-admin",
1,
"List all available commands for admin only",
this.create_array([
"restart",
"m | message",
"mt | message-to",
"w | welcome",
"name",
"password",
"k | kick",
"b | ban",
"tp | teleport",
"tpa | teleport-all",
"tpt | teleport-to",
"pos",
"heal",
"cancel-craft",
"da | disable-attack",
"pvp | disable-pvp",
"dgs | disable-gather-score",
"drs | disable-resource",
"dms | disable-mob-safety",
"ds | disable-shop",
"dn | disable-nickname",
"dch | disable-chat",
"dq | disable-quest",
"dd | disable-drop",
"ddc | disable-drop-crate",
"db | disable-crate",
"dwg | disable-warm-gauge",
"dk | disable-kit",
"dc | disable-craft",
"dr | disable-recycling",
"disable-clock",
"disable-recipes-book",
"disable-market",
"sb | spawn-building",
"fsb | force-spawn-building",
"sch | spawn-chest",
"spawn-area",
"spawn-area-team",
"cl | clean-position",
"cba | clean-building-all",
"ci | clean-inventory",
"cia | clean-inventory-all",
"harvest",
"gs | give-score",
"gsa | give-score-all",
"rs | reset-score",
"rk | reset-kill",
"gm | godmode",
"instant-craft",
"ka | kill-animals",
"g | give",
"ga | give-to-all",
"ri | remove-item",
"ria | remove-item-all",
"spawn-location",
"tm | team-mode",
"default-nickname",
"mm | murder-mode",
"br | battle-royale",
"help-config",
"gc | get-config",
"sc | set-config",
"reset-config",
"save-config",
"reset-event-time"
])
);
return true;
case "help":
this.write_command("help", 1, "List all available commands", this.create_array(["clean", "list", "pos", "help-admin", "help", "weapon-list", "tool-list", "survival-list", "resource-list", "food-list", "hat-list", "building-list", "biome-list"]));
return true;
}
return false;
},
_open: function () {
/* Open terminal input */
if (!this.open) {
this.open = true;
this.style.display = "inline-block";
this.input.focus();
this.commandIndex = 0;
}
},
_send: function () {
var msg = this.input.value;
const lastCommand = this.lastCommands[this.lastCommands.length - 1];
if (msg && msg.length > 0) {
if (this.lastCommands.length < 100 && msg !== lastCommand) {
this.lastCommands.push(msg);
} else if (msg !== lastCommand) {
this.lastCommands.push(msg);
this.lastCommands.splice(0, 1);
}
if (!this.commands(msg)) client.send_command(this.input.value);
this.input.value = "";
}
}
};
this.chat = {
open: false,
input: window.document.getElementById("chat_input"),
style: window.document.getElementById("chat_block").style,
update: function () {
this.style.left = window.Math.floor(canw / 2 - 150) + "px";
this.style.top = window.Math.floor(canh / 2 + 80) + "px";
},
quit: function () {
this.open = false;
this.style.display = "none";
this.input.value = "";
},
prefix: "!",
cmd: {
hud: function (param) {
if (param === "off") {
var msg = 'Enter "!hud" without the quotes to restore the HUD';
if (!user.alert.text) user.alert.text = msg;
else user.alert.list.push(msg);
game.show_ui = 0;
} else game.show_ui = 1;
}
},
commands: function (msg) {
/* Is the message a command ? */
if (msg.startsWith(this.prefix)) {
var cmd = "";
var param = "";
/* Extract message */
for (var i = 1; i < msg.length && msg.charAt(i) != " "; i++) cmd += msg.charAt(i);
/* Extract parameters */
i++;
for (; i < msg.length; i++) param += msg.charAt(i);
var fun = this.cmd[cmd];
if (fun) fun(param);
return true;
} else return false;
},
run: function () {
/* Skip chat if user still display a message */
/* Open chat input */
if (!this.open) {
this.open = true;
this.style.display = "inline-block";
this.input.focus();
/* Send chat message */
} else {
this.open = false;
this.style.display = "none";
var msg = this.input.value;
if (msg) {
if (!this.commands(msg)) client.send_chat(this.input.value);
this.input.value = "";
}
}
}
};
this.ash = {
flakes: [],
update: function (f) {
f.y += delta * 80 * f.s;
f.x += delta * 80 * f.c;
f.life -= delta / 6;
if (f.life > 0.2) f.alpha = window.Math.min(f.alpha + delta * 3, 1);
else f.alpha = window.Math.max(f.alpha - delta * 1, 0);
},
add: function () {
var length = window.Math.floor(window.Math.min(SPRITE.ASHES_NUMBER * (canw / 1366), SPRITE.ASHES_NUMBER + 10) * window.Math.max(window.Math.min(world.dist_lava + 1000, 3000) / 3000, 0));
if (this.flakes.length < length) {
var id = window.Math.floor(window.Math.random() * SPRITE.ASHES_SIZES);
var x = -user.cam.x + window.Math.floor(window.Math.random() * canw);
var y = -user.cam.y + window.Math.floor(window.Math.random() * canh);
var angle = window.Math.random(window.Math.PI);
this.flakes.push(new Flake(id, x, y, angle));
}
}
};
this.blizzard = 0;
this.bandage = 0;
this.captcha = "";
this.desert = {
flakes: [],
tempest: 0,
tempest_speed: 0,
update: function (f) {
f.y += delta * (200 + 800 * this.tempest_speed) * f.s;
f.x += delta * (200 + 800 * this.tempest_speed) * f.c;
f.life -= delta / 6;
if (f.life > 0.2) f.alpha = window.Math.min(f.alpha + delta * 3, 1);
else f.alpha = window.Math.max(f.alpha - delta * 1, 0);
},
add: function (pos) {
var length = window.Math.floor(window.Math.min((this.tempest_speed + 0.1) * SPRITE.SAND_NUMBER * (canw / 1366), (this.tempest_speed + 0.1) * SPRITE.SAND_NUMBER + 10) * window.Math.max(window.Math.min(world.dist_desert + 1000, 3000) / 3000, 0));
if (this.flakes.length < length) {
var id = window.Math.floor(window.Math.random() * SPRITE.ASHES_SIZES);
var x = -user.cam.x + window.Math.floor(window.Math.random() * canw);
var y = -user.cam.y + window.Math.floor(window.Math.random() * canh);
var angle = window.Math.random(window.Math.PI);
if (user.desert.tempest !== 0) x -= canw / 2;
this.flakes.push(new Flake(id, x, y, angle));
}
}
};
this.winter = {
flakes: [],
tempest: 0,
tempest_speed: 0,
update: function (f) {
if (keyboard.is_bottom()) f.y += delta * f.speed * (5.5 + 10 * this.tempest_speed);
else f.y += delta * f.speed * (5 + 10 * this.tempest_speed);
f.life -= delta / 2;
if (keyboard.is_left()) f.x += delta * (100 + 400 * this.tempest_speed);
else if (keyboard.is_right()) f.x -= delta * (130 - 400 * this.tempest_speed);
else f.x -= delta * (30 - 400 * this.tempest_speed);
if (f.life > 0.2) f.alpha = window.Math.min(f.alpha + delta * 3, 1);
else f.alpha = window.Math.max(f.alpha - delta * 5, 0);
},
add: function () {
var length = window.Math.floor(window.Math.min((this.tempest_speed * 1.5 + 0.5) * SPRITE.FLAKES_NUMBER * (canw / 1366), (this.tempest_speed * 1.5 + 0.5) * SPRITE.FLAKES_NUMBER + 10) * window.Math.max(window.Math.min(world.dist_winter + 1000, 3000) / 3000, 0));
if (this.flakes.length < length) {
var id = window.Math.floor(window.Math.random() * SPRITE.FLAKES_SIZES);
var x = -user.cam.x + window.Math.floor(window.Math.random() * canw);
var y = -user.cam.y + window.Math.floor(window.Math.random() * 400 * scale - 200 * scale);
this.flakes.push(new Flake(id, x, y, 0));
}
}
};
function Beach() {
this.seed = 1;
this.seed2 = 2;
this.seed3 = 3;
this.seedv = 1;
this.seedv2 = 2;
this.seedv3 = 3;
this.new_seed = function (x) {
this.seed = 2 + window.Math.floor(window.Math.random() * WORLD.SEED);
};
this.new_seed2 = function (x) {
this.seed2 = 2 + window.Math.floor(window.Math.random() * WORLD.SEED);
};
this.new_seed3 = function (x) {
this.seed3 = 2 + window.Math.floor(window.Math.random() * WORLD.SEED);
};
this.new_seedv = function (x) {
this.seedv = 2 + window.Math.floor(window.Math.random() * WORLD.SEED);
};
this.new_seedv2 = function (x) {
this.seedv2 = 2 + window.Math.floor(window.Math.random() * WORLD.SEED);
};
this.new_seedv3 = function (x) {
this.seedv3 = 2 + window.Math.floor(window.Math.random() * WORLD.SEED);
};
this.draw_foam_vert = function (y, p, seed, r1, r2, _left, _right) {
for (var i = 1; i < _right;) {
/* Get random value */
var j = (i * seed) % RAND_SIZE;
var v = RANDOM[j];
/* Make gap */
if (v < 0.1) {
r += 50;
i += 50;
continue;
}
/* Move randomly the floam */
var r = window.Math.floor(v * r1 + r2);
if (i > _left && i < _right) {
/* Compute random sign */
var s = window.Math.random() > 0.5 ? -10 * delta : 10 * delta;
var radius = r * p;
this.bxv[j] = window.Math.max(-WORLD.FLOAM_X, window.Math.min(WORLD.FLOAM_X, this.bxv[j] + s));
this.byv[j] = window.Math.max(-WORLD.FLOAM_Y, window.Math.min(WORLD.FLOAM_Y, this.byv[j] + s));
/* Draw floam bubbles */
if (radius > 0) {
ctx.beginPath();
ctx.arc(i + user.cam.x + this.byv[j], y + this.bxv[j] - WORLD.FLOAM_X * 0.8, radius, 0, PI2M);
if (world.transition) {
var shade = world.time ? 1 - world.shade.v : world.shade.v;
ctx.fillStyle = get_color_transition(0x53, 0x9c, 0xa0, 0xec, 0xf7, 0xf9, shade);
} else ctx.fillStyle = SPRITE.FLOAM_COLOR[world.time];
ctx.fill();
}
}
i += 2 * r;
}
};
this.draw_foam = function (x, p, seed, r1, r2, _top, _bottom) {
for (var i = 1; i < _bottom;) {
/* Get random value */
var j = (i * seed) % RAND_SIZE;
var v = RANDOM[j];
/* Make gap */
if (v < 0.1) {
r += 50;
i += 50;
continue;
}
/* Move randomly the floam */
var r = window.Math.floor(v * r1 + r2);
if (i > _top && i < _bottom) {
/* Compute random sign */
var s = window.Math.random() > 0.5 ? -10 * delta : 10 * delta;
var radius = r * p;
this.bx[j] = window.Math.max(-WORLD.FLOAM_X, window.Math.min(WORLD.FLOAM_X, this.bx[j] + s));
this.by[j] = window.Math.max(-WORLD.FLOAM_Y, window.Math.min(WORLD.FLOAM_Y, this.by[j] + s));
/* Draw floam bubbles */
if (radius > 0) {
ctx.beginPath();
ctx.arc(x + this.bx[j] - WORLD.FLOAM_X * 0.8, i + user.cam.y + this.by[j], radius, 0, PI2M);
if (world.transition) {
var shade = world.time ? 1 - world.shade.v : world.shade.v;
ctx.fillStyle = get_color_transition(0x53, 0x9c, 0xa0, 0xec, 0xf7, 0xf9, shade);
} else ctx.fillStyle = SPRITE.FLOAM_COLOR[world.time];
ctx.fill();
}
}
i += 2 * r;
}
};
this.draw_foams_bottom = function (y, y2, y3, diff_y, _left, _right) {
_left -= 30;
_right += 30;
var p = -((y3 - WORLD.LW1SX - diff_y - 2) / WORLD.W1EX);
if (p === 0) this.new_seed3();
ctx.globalAlpha = Utils.ease_in_out_quad(p);
this.draw_foam_vert(y3, p, this.seed3, 18, 16, _left, _right);
ctx.globalAlpha = 1;
var p = -((y - WORLD.LW2SX - diff_y + 500) / WORLD.W2EX);
if (p === 0) this.new_seed();
ctx.globalAlpha = Utils.ease_in_out_quad(p);
this.draw_foam_vert(y, p, this.seed, 12, 10, _left, _right);
ctx.globalAlpha = 1;
if (y2 === -1) return;
var p = -((y2 - WORLD.LW3SX - diff_y + 698) / WORLD.W3EX);
if (p <= 0.01) this.new_seed2();
ctx.globalAlpha = Utils.ease_in_out_quad(p);
this.draw_foam_vert(y2, p, this.seed2, 6, 6, _left, _right);
ctx.globalAlpha = 1;
};
this.draw_foams_top = function (y, y2, y3, diff_y, _left, _right) {
_left -= 30;
_right += 30;
var p = -((-y3 + WORLD.LW1SX + diff_y + 2) / WORLD.W1EX);
if (p === 0) this.new_seed3();
ctx.globalAlpha = Utils.ease_in_out_quad(p);
this.draw_foam_vert(y3, p, this.seed3, 18, 16, _left, _right);
ctx.globalAlpha = 1;
var p = -((-y + WORLD.LW2SX + diff_y) / WORLD.W2EX);
if (p === 0) this.new_seed();
ctx.globalAlpha = Utils.ease_in_out_quad(p);
this.draw_foam_vert(y, p, this.seed, 12, 10, _left, _right);
ctx.globalAlpha = 1;
if (y2 === -1) return;
var p = -((-y2 + WORLD.LW3SX + diff_y) / WORLD.W3EX);
if (p <= 0.01) this.new_seed2();
ctx.globalAlpha = Utils.ease_in_out_quad(p);
this.draw_foam_vert(y2, p, this.seed2, 6, 6, _left, _right);
ctx.globalAlpha = 1;
};
this.draw_foams_left = function (x, x2, x3, diff_x, _top, _bottom) {
_top -= 30;
_bottom += 30;
var p = -((-x3 + WORLD.LW1SX + diff_x + 2) / WORLD.W1EX);
if (p === 0) this.new_seed3();
ctx.globalAlpha = Utils.ease_in_out_quad(p);
this.draw_foam(x3, p, this.seed3, 18, 16, _top, _bottom);
ctx.globalAlpha = 1;
var p = -((-x + WORLD.LW2SX + diff_x) / WORLD.W2EX);
if (p === 0) this.new_seed();
ctx.globalAlpha = Utils.ease_in_out_quad(p);
this.draw_foam(x, p, this.seed, 12, 10, _top, _bottom);
ctx.globalAlpha = 1;
if (x2 === -1) return;
var p = -((-x2 + WORLD.LW3SX + diff_x) / WORLD.W3EX);
if (p <= 0.01) this.new_seed2();
ctx.globalAlpha = Utils.ease_in_out_quad(p);
this.draw_foam(x2, p, this.seed2, 6, 6, _top, _bottom);
ctx.globalAlpha = 1;
};
this.draw_foams_right = function (x, x2, x3, diff_x, _top, _bottom) {
_top -= 30;
_bottom += 30;
var p = -((x3 - WORLD.LW1SX - diff_x - 2) / WORLD.W1EX);
if (p === 0) this.new_seed3();
ctx.globalAlpha = Utils.ease_in_out_quad(p);
this.draw_foam(x3, p, this.seed3, 18, 16, _top, _bottom);
ctx.globalAlpha = 1;
var p = -((x - WORLD.LW2SX - diff_x + 500) / WORLD.W2EX);
if (p === 0) this.new_seed();
ctx.globalAlpha = Utils.ease_in_out_quad(p);
this.draw_foam(x, p, this.seed, 12, 10, _top, _bottom);
ctx.globalAlpha = 1;
if (x2 === -1) return;
var p = -((x2 - WORLD.LW3SX - diff_x + 698) / WORLD.W3EX);
if (p <= 0.01) this.new_seed2();
ctx.globalAlpha = Utils.ease_in_out_quad(p);
this.draw_foam(x2, p, this.seed2, 6, 6, _top, _bottom);
ctx.globalAlpha = 1;
};
this.w1 = {
r: new Ease(Utils.ease_out_cubic, 0, 10, WORLD.W1SX, WORLD.W1SX, WORLD.W1EX),
l: new Ease(Utils.ease_in_out_cubic, 0, 10, WORLD.W1EX, WORLD.W1EX, WORLD.W1SX)
};
this.w2 = {
r: new Ease(Utils.ease_out_quart, 0, 10, WORLD.W2SX, WORLD.W2SX, WORLD.W2EX),
l: new Ease(Utils.ease_in_out_quad, 0, 10, WORLD.W2EX, WORLD.W2EX, WORLD.W2SX)
};
this.w3 = {
r: new Ease(Utils.ease_out_quint, 0, 10, WORLD.W3SX, WORLD.W3SX, WORLD.W3EX),
l: new Ease(Utils.ease_in_out_quad, 0, 10, WORLD.W3EX, WORLD.W3EX, WORLD.W3SX)
};
this.t_ = function (w_) {
var w;
if (w_.r.x === w_.r.ex) {
if (w_.l.x === w_.l.ex) {
w = w_.r;
} else w = w_.l;
} else w = w_.r;
return w;
};
this.t = function (w_) {
var w;
if (w_.r.x === w_.r.ex) {
if (w_.l.x === w_.l.ex) {
w_.r.restart();
w_.l.restart();
w = w_.r;
} else w = w_.l;
} else w = w_.r;
w.ease(w.ex);
return w;
};
this.bx = [];
this.by = [];
this.bxv = [];
this.byv = [];
this.init = function () {
for (var i = 0; i < RAND_SIZE; i++) {
this.bx[i] = window.Math.floor(RANDOM[i] * WORLD.FLOAM_X);
this.by[i] = window.Math.floor(RANDOM[i] * WORLD.FLOAM_Y);
this.bxv[i] = window.Math.floor(RANDOM[i] * WORLD.FLOAM_X);
this.byv[i] = window.Math.floor(RANDOM[i] * WORLD.FLOAM_Y);
}
this.w1.r.x = this.w1.r.ex;
this.w2.r.ed = 3.5;
this.w3.r.ed = 2;
};
this.init();
}
this.beach = [];
for (var i = 0; i < 4; i++) this.beach.push(new Beach());
}
}
class Loader {
constructor(can, ctx, after_loading_stuff) {
this.can = can;
this.ctx = ctx;
/* Misc objects */
this.logo = {
translate: { x: 0, y: 0 },
style: window.document.getElementById("loading").style,
update: function () {
this.style.left = this.translate.x + "px";
this.style.top = window.Math.floor(this.translate.y) + "px";
}
};
this.logo.style.position = "absolute";
this.logo.style.display = "inline-block";
this.logo.update();
/* Check if loader is running */
this.is_run = true;
this.stop = function () {
this.is_run = false;
};
/* Create object of loader */
this.loading = { total: 1 /* load images */ };
/* WATCH OUT, I'M NOT SURE ABOUT THIS TRICK, IT MAY BE A SOURCE OF BUG *
* That seem work for use this object in a event listener */
var _this = this;
/* Quit effect, all content escape from the top */
var fun_after_quit = function () { };
var quit_effect_step = 0;
var quit_effect_max_step = 60;
this.quit_effect = function () {
_this.update();
quit_effect_step++;
if (quit_effect_step == quit_effect_max_step) {
_this.stop();
fun_after_quit();
return;
}
window.setTimeout(_this.quit_effect, CONFIG.frameTimeout);
};
/* Quit with nice effect and run next funtion */
this.quit = function (fun) {
/* Will be run after quit */
fun_after_quit = fun;
_this.quit_effect();
};
/* Load funtion image */
var TIMEDEBUG_IMAGE = new window.Date().getTime();
function need_to_load_this_image(name) {
if (name.indexOf("normal-mode") !== -1 || name.indexOf("player0") !== -1) return 1;
if (
name.indexOf("day-bag") !== -1 ||
name.indexOf("night-bag") !== -1 ||
name.indexOf("day-book") !== -1 ||
name.indexOf("night-book") !== -1 ||
name.indexOf("day-player") !== -1 ||
name.indexOf("night-player") !== -1 ||
name.indexOf("day-accessory") !== -1 ||
name.indexOf("night-accessory") !== -1 ||
name.indexOf("day-crate") !== -1 ||
name.indexOf("night-crate") !== -1 ||
name.indexOf("day-skin") !== -1 ||
name.indexOf("night-skin") !== -1 ||
name.indexOf("day-river") !== -1 ||
name.indexOf("night-river") !== -1 ||
name.indexOf("day-river") !== -1 ||
name.indexOf("night-river") !== -1 ||
name.indexOf("day-rock") !== -1 ||
name.indexOf("night-rock") !== -1 ||
name.indexOf("day-flower") !== -1 ||
name.indexOf("night-flower") !== -1 ||
name.indexOf("day-leaf") !== -1 ||
name.indexOf("night-leaf") !== -1 ||
name.indexOf("day-herb") !== -1 ||
name.indexOf("night-herb") !== -1 ||
name.indexOf("day-shell") !== -1 ||
name.indexOf("night-shell") !== -1 ||
name.indexOf("day-hand-skin") !== -1 ||
name.indexOf("night-hand-skin") !== -1 ||
name.indexOf("bignight") !== -1 ||
name.indexOf("bigday") !== -1 ||
name.indexOf("bigzday") !== -1 ||
name.indexOf("bigznight") !== -1 ||
name.indexOf("tutorial-box") !== -1 ||
name.indexOf("-leaderboard-") !== -1 ||
name.indexOf("-lead-") !== -1 ||
name.indexOf("day-lava-") !== -1 ||
name.indexOf("night-lava-") !== -1 ||
name.indexOf("-click.png") !== -1 ||
name.indexOf("-in.png") !== -1 ||
name.indexOf("-fog") !== -1 ||
name.indexOf("-lava") !== -1 ||
name.indexOf("pebblecompo") !== -1 ||
name.indexOf("avatar-player") !== -1
)
return 0;
return 1;
}
var number_img_to_load = Object.keys(IMAGES).length;
for (var img in IMAGES) {
if (need_to_load_this_image(IMAGES[img]) === 0) number_img_to_load--;
}
var my_loader_fun = function () {
if (this.isLoaded !== 0) return this.isLoaded;
this.isLoaded = 2;
this.src = this._src;
return 0;
};
var my_onload_fun = function (a) {
this.isLoaded = 1;
};
var already_had_server_info = 0;
var receive_server_info = function () {
/* Call quit effect */
if (already_had_server_info === 1) return;
already_had_server_info = 1;
var privateServerName = Utils.getURLData("server");
if (privateServerName !== null) {
client.privateServer = 1;
client.server_list = [{ nu: 0, m: 100, i: "server" + privateServerName + ".starver.io", p: 443, a: "Private Server " + privateServerName, ssl: true }];
}
client.update_server_list();
window.setTimeout(after_loading_stuff, 100);
};
var wait_font = function () {
let request_server_info = async () => {
await client.fetch_server_list();
receive_server_info();
};
if (!window.document.fonts || !window.document.fonts.check) window.setTimeout(request_server_info, 1000);
else if (window.document.fonts.check("1em Baloo Paaji")) window.setTimeout(request_server_info, 100);
else window.setTimeout(wait_font, 100);
};
var my_onerror_fun = function () {
var _src = this.src;
var _wait = need_to_load_this_image(_src) === 0 ? 10000 : 2000;
window.setTimeout(function () {
for (var i in DUMP_IMAGES) {
if (_src.indexOf(DUMP_IMAGES[i]) !== -1) {
IMAGES[i] = new Image();
IMAGES[i].onload = my_onload_fun;
IMAGES[i].onerror = my_onerror_fun;
IMAGES[i].src = _src;
break;
}
}
}, _wait);
};
/* Load sprite and all stuff */
function load_images(priority) {
for (var i in IMAGES) {
var src = "img/" + IMAGES[i] + ".png";
// Skip already loaded image
if (typeof src !== "string") continue;
// Skip image that does not match the priority
if (need_to_load_this_image(src) !== priority) continue;
IMAGES[i] = new Image();
IMAGES[i].isLoaded = 0;
IMAGES[i].onload = my_onload_fun;
IMAGES[i].onerror = my_onerror_fun;
IMAGES[i].tryLoad = my_loader_fun;
if (window["location"]["protocol"] !== "https:") IMAGES[i]._src = src;
else IMAGES[i]._src = window["location"].href + src;
}
}
// Firstly load all image with high priority
load_images(1);
// Then load images with low priority
load_images(0);
// Try to force loading ?
create_text(1, "l", 20, "#000000");
wait_font();
window.bas = client.server_list
// generate the image query selector
_load_images();
/* Update position of object, usefull for trigger */
this.update = function () {
this.logo.translate.x = (canw - 500) / 2;
this.logo.translate.y = (canh - 150) / 2;
/* Quit effect */
var move_effect = 2500 / (quit_effect_max_step - quit_effect_step + 1) - 24;
// I substract 48 for avoid move_effect when no using -> when quit_effect_step == 0
this.logo.translate.y -= move_effect;
this.logo.update();
};
this.logo.update();
this.draw = function () {
/* Draw fake world */
draw_fake_world();
/* Update position */
this.update();
};
}
}
document.addEventListener
class UI {
constructor(can, ctx) {
this.can = can;
this.ctx = ctx;
/* Edge does not provide image for cursor feature */
if (window.navigator.userAgent.indexOf("Edge") > -1) {
this.cursor0 = "default";
this.cursor1 = "pointer";
} else {
this.cursor0 = "url('img/cursor0.png'), default";
this.cursor1 = "url('img/cursor1.png'), pointer";
}
/* WATCH OUT, I'M NOT SURE ABOUT THIS TRICK, IT MAY BE A SOURCE OF BUG *
* That seem work for use this object in a event listener */
var _this = this;
/* Waiting the connection */
this.waiting = false;
/* In UI or outside */
this.in_this_view = 0;
/* Current mode score selected */
this.current_mode_score = -1;
/* Loading effect */
this.loading = {
translate: { x: 0, y: 0 },
angle: 0,
img: sprite[SPRITE.GEAR2],
draw: function () {
this.angle += delta * 2;
ctx.save();
ctx.translate(this.translate.x + this.img.width / 2, this.translate.y + this.img.height / 2);
ctx.rotate(this.angle);
ctxDrawImage(ctx, this.img, -this.img.width / 2, -this.img.height / 2);
ctx.restore();
}
};
this.bread = 0;
this.previous_bread = -1;
this.bread_img = undefined;
this.new_nickname = "";
this.previous_new_nickname = "";
this.new_nickname_img = undefined;
this.lvl = 0;
this.previous_lvl = -1;
this.lvl_img = undefined;
this.xp = 0;
this.xp_dest = 0;
this.firstName = 0;
this.kill = 0;
this.death = 0;
this.time = 0;
this.score = 0;
this.scoreTotal = 0;
this.bestKill = 0;
this.bestTime = 0;
this.bestScore = 0;
this.seasons = [];
this.kit = -1;
this.previous_kit_hour = -1;
this.previous_kit_min = -1;
this.kit_img_min = undefined;
this.kit_img_hour = undefined;
this.privateServerTime = -1;
this.previous_privateServerTime_day = -1;
this.previous_privateServerTime_hour = -1;
this.previous_privateServerTime_min = -1;
this.privateServerTime_img_min = undefined;
this.privateServerTime_img_hour = undefined;
this.privateServerTime_img_day = undefined;
this.cosmetic_name = undefined;
this.cosmetic_author = undefined;
this.leaderboard_range = undefined;
this.leaderboard_mode = undefined;
this.leaderboard_sorted = undefined;
this.leaderboard_season = 0;
this.profile_season = 0;
this.breath = 0;
function CosmeticSelector(___type, first, ___setter, firstId, unlock) {
var __this = this;
var last = first + 9;
var cursor = 0;
var currentId = firstId;
// Init first button
for (var i = first; i < last; i++) {
_this.buttons[i].info.callback = onClickCosmetic;
_this.buttons[i].info.cosmeticType = ___type;
}
function loadText() {
var info = ___type[currentId];
ui.cosmetic_name = gui_render_text(info.name, "'Baloo Paaji', sans-serif", "#EFE4B4", 30, 350, undefined, 10, 8);
if (info.level !== undefined) ui.cosmetic_author = gui_render_text("Level " + info.level, "'Baloo Paaji', sans-serif", "#EFE4B4", 30, 250, undefined, 10, 8);
else ui.cosmetic_author = gui_render_text("by " + info.author, "'Baloo Paaji', sans-serif", "#EFE4B4", 30, 250, undefined, 10, 8);
}
function onClickCosmetic() {
if (currentId === this.cosmeticId || this.cosmeticId === -1) return;
// Display locked info box
if (this.unlocked > 0) {
if (first === FIRST_BUTTON_SKIN) update_subview(__LOCKED_SKIN__, __HIDE__, "none");
else update_subview(__LOCKED_ACC__, __HIDE__, "none");
} else {
if (first === FIRST_BUTTON_SKIN) update_subview(__LOCKED_SKIN__, __DISPLAY__, "inline-block");
else update_subview(__LOCKED_ACC__, __DISPLAY__, "inline-block");
}
currentId = this.cosmeticId;
___setter(this.cosmeticId);
loadText();
}
function moveNext() {
if (cursor * 3 + 9 < ___type.length) cursor++;
__this.initSelector();
}
function movePrevious() {
if (cursor > 0) cursor--;
__this.initSelector();
}
function initSelector() {
for (var i = first, j = cursor * 3; i < last && j < ___type.length; i++, j++) {
if (___type[j].rarity === RARITY.SPECIAL && unlock[j] === 0) {
_this.buttons[i].info.cosmeticId = -1;
_this.buttons[i].info.active = __HIDE__;
continue;
}
_this.buttons[i].info.cosmeticId = j;
for (var k = 0; k < 3; k++) {
_this.buttons[i].info.img[k] = RARITY_BUTTON[___type[j].rarity][k];
_this.buttons[i].info.active = __DISPLAY__;
_this.buttons[i].info.unlocked = unlock[j];
}
}
for (; i < last; i++) {
_this.buttons[i].info.cosmeticId = -1;
_this.buttons[i].info.active = __HIDE__;
}
loadText();
}
this.initSelector = initSelector;
_this.buttons[last].info.callback = movePrevious;
_this.buttons[last + 1].info.callback = moveNext;
}
/* Open window of settings */
this.settings = false;
this.quality = cookiesManager.get("starve_quality") ? cookiesManager.get("starve_quality") : "high";
if (this.quality === "high") {
window.document.getElementById("high_ing").style.backgroundColor = "#B56D18";
window.document.getElementById("low_ing").style.backgroundColor = "#3A2A0D";
this.quality = 1;
} else {
window.document.getElementById("low_ing").style.backgroundColor = "#B56D18";
window.document.getElementById("high_ing").style.backgroundColor = "#3A2A0D";
this.quality = 0;
}
this.high_quality = function () {
window.document.getElementById("high_ing").style.backgroundColor = "#B56D18";
window.document.getElementById("low_ing").style.backgroundColor = "#3A2A0D";
cookiesManager.set("starve_quality", "high", 30);
window.document.getElementById("input_ratio").value = 1;
game.change_ratio();
ui.quality = 1;
};
this.low_quality = function () {
window.document.getElementById("high_ing").style.backgroundColor = "#3A2A0D";
window.document.getElementById("low_ing").style.backgroundColor = "#B56D18";
cookiesManager.set("starve_quality", "low", 30);
window.document.getElementById("input_ratio").value = 0.5 / (devicePixelRatio / backingStoreRatio);
game.change_ratio();
ui.quality = 0;
};
if (cookiesManager.get("starve_mapping") === undefined && lang === "FR") {
keyboard.set_azerty();
this.mapping = "azerty";
} else this.mapping = cookiesManager.get("starve_mapping") ? cookiesManager.get("starve_mapping") : "qwerty";
if (this.mapping == "azerty") {
keyboard.set_azerty();
window.document.getElementById("azerty_ing").style.backgroundColor = "#B56D18";
window.document.getElementById("qwerty_ing").style.backgroundColor = "#3A2A0D";
} else {
window.document.getElementById("qwerty_ing").style.backgroundColor = "#B56D18";
window.document.getElementById("azerty_ing").style.backgroundColor = "#3A2A0D";
}
this.set_azerty = function () {
keyboard.set_azerty();
window.document.getElementById("azerty_ing").style.backgroundColor = "#B56D18";
window.document.getElementById("qwerty_ing").style.backgroundColor = "#3A2A0D";
cookiesManager.set("starve_mapping", "azerty", 30);
};
this.set_qwerty = function () {
keyboard.set_qwerty();
window.document.getElementById("azerty_ing").style.backgroundColor = "#3A2A0D";
window.document.getElementById("qwerty_ing").style.backgroundColor = "#B56D18";
cookiesManager.set("starve_mapping", "qwerty", 30);
};
function init_skin() {
var ct = window.Number(cookiesManager.get("starve_crate"));
var dd = window.Number(cookiesManager.get("starve_dead"));
var bk = window.Number(cookiesManager.get("starve_book"));
var bg = window.Number(cookiesManager.get("starve_bag"));
var sk = window.Number(cookiesManager.get("starve_skin"));
var ac = window.Number(cookiesManager.get("starve_accessory"));
_this.skin = sk ? sk : 0;
_this.book = bk ? bk : 0;
_this.crate = ct ? ct : 1;
_this.accessory = ac ? ac : 0;
_this.bag = bg ? bg : 0;
_this.dead = dd ? dd : 0;
}
init_skin();
this.unlock = {};
this.unlock.skin = [];
this.unlock.bag = [];
this.unlock.book = [];
this.unlock.crate = [];
this.unlock.dead = [];
this.unlock.accessory = [];
this.day_mode = 0;
/* Unlock cosmetics */
function unlock_cosmetics() {
var cosmetic = COSMETICS.SKIN;
for (var i = 0; i < cosmetic.length; i++) {
if (cosmetic[i].rarity === RARITY.FREE)
_this.unlock.skin[i] = 1;
else _this.unlock.skin[i] = 0;;
}
var cosmetic = COSMETICS.ACCESSORY;
for (var i = 0; i < cosmetic.length; i++) {
if (cosmetic[i].rarity === RARITY.FREE)
_this.unlock.accessory[i] = 1;
else _this.unlock.accessory[i] = 0;
}
var cosmetic = COSMETICS.BAG;
for (var i = 0; i < cosmetic.length; i++) {
if (cosmetic[i].rarity === RARITY.FREE)
_this.unlock.bag[i] = 1;
else _this.unlock.bag[i] = 0;
}
var cosmetic = COSMETICS.BOOK;
for (var i = 0; i < cosmetic.length; i++) {
if (cosmetic[i].rarity === RARITY.FREE)
_this.unlock.book[i] = 1;
else _this.unlock.book[i] = 0;
}
var cosmetic = COSMETICS.CRATE;
for (var i = 0; i < cosmetic.length; i++) {
if (cosmetic[i].rarity === RARITY.FREE) {
_this.unlock.crate[i] = 1;
_this.unlock.dead[i] = 1;
} else {
_this.unlock.crate[i] = 0;
_this.unlock.dead[i] = 0;
}
}
}
this.unlock_cosmetics = unlock_cosmetics;
unlock_cosmetics();
/* Appear effect, all content appear from the bottom */
var appear_effect_step = 0;
var appear_effect_max_step = 60;
var appear_effect = function () {
_this.update();
appear_effect_step++;
if (appear_effect_step == appear_effect_max_step) {
_this.add_event_listener();
_this.in_this_view = true;
_this.update();
return;
}
window.setTimeout(appear_effect, CONFIG.frameTimeout);
};
/* Quit UI with nicke effect */
this.quit = function (fun) {
/* Will be run after quit */
fun_after_quit = fun;
/* Clean menu trigger */
_this.remove_event_listener();
_this.in_this_view = 0;
/* Make nice quit effect */
quit_effect_step = -1;
quit_effect();
};
/* Quit effect, all content escape from the top */
var fun_after_quit;
var quit_effect_step = -1;
var quit_effect_max_step = 60;
var quit_effect = function () {
_this.update();
quit_effect_step++;
if (quit_effect_step == quit_effect_max_step) {
cookiesManager.set("starve_nickname", _this.nickname.input.value, 30);
_this.nickname.style.display = "none";
_this.server_list.style.display = "none";
_this.stop();
fun_after_quit();
return;
}
window.setTimeout(quit_effect, CONFIG.frameTimeout);
};
/* Check if user interface is running */
this.is_run = false;
this.stop = function () {
this.is_run = false;
};
/* Run the user interface, make effect and add event listener */
this.run = function () {
/* Reset ground color */
window.document.getElementById("game_body").style.backgroundColor = SPRITE.GROUND[fake_world.time];
/* Reset ui css interface */
_this.nickname.style.display = "inline-block";
_this.server_list.style.display = "inline-block";
_this.waiting = false;
_this.is_run = true;
quit_effect_step = -1;
appear_effect_step = 0;
appear_effect();
};
/**
* Update UIComponent position
* @param {UIComponent} component
* @param {number} effect
*/
this.update_component = function (component, effect) {
effect = effect < 0 ? -effect : effect;
// Update component position
if ((component.position & __MIDDLE_X__) === __MIDDLE_X__) {
if ((component.position & __LEFT__) === __LEFT__) component.translate.x = canw2 + component.translate._x - effect;
else if ((component.position & __RIGHT__) === __RIGHT__) component.translate.x = canw2 + component.translate._x + effect;
else component.translate.x = canw2 + component.translate._x;
} else if ((component.position & __LEFT__) === __LEFT__) component.translate.x = component.translate._x - effect;
else if ((component.position & __RIGHT__) === __RIGHT__) component.translate.x = canw - component.translate._x + effect;
else component.translate.x = component.translate._x;
if ((component.position & __MIDDLE_Y__) === __MIDDLE_Y__) {
if ((component.position & __TOP__) === __TOP__) component.translate.y = canh2 + component.translate._y - effect;
else if ((component.position & __BOTTOM__) === __BOTTOM__) component.translate.y = canh2 + component.translate._y + effect;
else component.translate.y = canh2 + component.translate._y;
} else if ((component.position & __TOP__) === __TOP__) component.translate.y = component.translate._y - effect;
else if ((component.position & __BOTTOM__) === __BOTTOM__) component.translate.y = canh + component.translate._y + effect;
else component.translate.y = component.translate._y;
// Apply position for CSS component
if (component.style !== undefined) {
component.style.left = window.Math.floor(component.translate.x) + "px";
component.style.top = window.Math.floor(component.translate.y) + "px";
}
};
/* Update position of object, usefull for trigger */
this.update = function () {
// Compute transition effect
var effect = 0;
if (appear_effect_step != appear_effect_max_step || quit_effect_step != -1) {
/* Appear effect */
if (appear_effect_step != appear_effect_max_step)
// I substract 50 because at end, move effect do not down at 0
var effect = 1500 / (appear_effect_step + 1) - 25;
/* Quit effect */
if (quit_effect_step != -1)
// I substract 48 for center correctly -> when quit_effect_step == 0
var effect = -(1750 / (quit_effect_max_step - quit_effect_step + 1) - 24);
}
// Update background image component
for (var i = 0; i < this.bkgd.length; i++) this.update_component(this.bkgd[i], effect);
// Update buttons
for (var i = 0; i < this.buttons.length; i++) this.update_component(this.buttons[i].info, effect);
// Update CSS element
for (var i = 0; i < this.css.length; i++) this.update_component(this.css[i], effect);
this.loading.translate.x = (canw - this.loading.img.width) / 2;
this.loading.translate.y = 0;
if (appear_effect_step != appear_effect_max_step || quit_effect_step != -1) {
var move_effect = 0;
/* Appear effect */
if (appear_effect_step != appear_effect_max_step) {
var move_effect = 1500 / (appear_effect_step + 1) - 24;
// I substract 50 because at end, move effect do not down at 0
}
/* Quit effect */
if (quit_effect_step != -1) {
var move_effect = -(1750 / (quit_effect_max_step - quit_effect_step + 1) - 24);
// I substract 48 for center correctly -> when quit_effect_step == 0
}
this.loading.translate.y -= move_effect > 0 ? move_effect : -move_effect;
}
};
this.create_spin = function (info) {
var spin = window.document.createElement("canvas");
var spinCtx = spin.getContext("2d");
spin.width = 342;
spin.height = 342;
var start = -window.Math.PI / 2;
for (var i = 0; i < info.length; i++) {
var col = info[i][0];
var deg = (info[i][1] * window.Math.PI) / 180;
spinCtx.beginPath();
spinCtx.arc(171, 171, 170, start, start + deg, false);
spinCtx.lineTo(171, 171);
spinCtx.fillStyle = col;
spinCtx.fill();
start += deg;
}
return spin;
};
this.generate_new_nickname = function () {
// Draw text info
this.new_nickname = window.document.getElementById("account_nickname_input").value;
if (this.new_nickname !== this.previous_new_nickname) {
this.previous_new_nickname = this.new_nickname;
this.new_nickname_img = gui_render_text(this.new_nickname, "'Baloo Paaji', sans-serif", "#EFE4B4", 45, 550);
}
};
this.draw = function () {
/* Draw fake world */
draw_fake_world();
// Place experience gauge relatively to the top left interface
ui.xp = Utils.lerp(ui.xp, ui.xp_dest, 0.03);
this.bkgd[LEVEL_GAUGE].translate.x = this.bkgd[0].translate.x + -72 + 165 * ui.xp;
this.bkgd[LEVEL_GAUGE].translate._x = this.bkgd[LEVEL_GAUGE].translate.x;
this.bkgd[LEVEL_GAUGE].translate.y = this.bkgd[0].translate.y + 30;
this.bkgd[LEVEL_GAUGE].translate._y = this.bkgd[LEVEL_GAUGE].translate.y;
// Render all background images
for (var i = 2; i < this.bkgd.length; i++) {
if (this.bkgd[i].active === __DISPLAY__) this.bkgd[i].draw(ctx);
}
if (this.recaptcha.active === __DISPLAY__) {
this.buttons[NORMAL_MODE].info.translate.y = this.buttons[NORMAL_MODE].info.translate._oldy + 90;
this.buttons[MODE_COMMUNITY].info.translate.y = this.buttons[MODE_COMMUNITY].info.translate._oldy + 90;
this.buttons[MODE_EXPERIMENTAL].info.translate.y = this.buttons[MODE_EXPERIMENTAL].info.translate._oldy + 90;
} else {
this.buttons[NORMAL_MODE].info.translate.y = this.buttons[NORMAL_MODE].info.translate._oldy;
this.buttons[MODE_COMMUNITY].info.translate.y = this.buttons[MODE_COMMUNITY].info.translate._oldy;
this.buttons[MODE_EXPERIMENTAL].info.translate.y = this.buttons[MODE_EXPERIMENTAL].info.translate._oldy;
}
// Render kit remains time
var remains = this.kit - Date.now();
if (remains > 0) {
var min = window.Math.floor(remains / 60000);
var hour = window.Math.floor(min / 60);
min %= 60;
if (min !== this.previous_kit_min) {
this.previous_kit_min = min;
min = min < 10 ? "0" + min : "" + min;
_this.kit_img_min = gui_render_text(min, "'Baloo Paaji', sans-serif", "#EFE4B4", 80, 200);
}
if (hour !== this.previous_kit_hour) {
this.previous_kit_hour = hour;
hour = hour < 10 ? "0" + hour : "" + hour;
_this.kit_img_hour = gui_render_text(hour, "'Baloo Paaji', sans-serif", "#EFE4B4", 80, 200);
}
var remain_box = this.bkgd[BAG_REMAIN_BOX];
remain_box.draw(ctx);
var img = this.kit_img_hour;
ctxDrawImage(ctx, img, remain_box.translate.x - img.width / 4 + 182, remain_box.translate.y - img.height / 4 + 40, img.width / 2, img.height / 2);
var img = this.kit_img_min;
ctxDrawImage(ctx, img, remain_box.translate.x - img.width / 4 + 251, remain_box.translate.y - img.height / 4 + 40, img.width / 2, img.height / 2);
}
// Render privateServerTime remains time
var remains = this.privateServerTime - Date.now();
if (remains > 0) {
var min = window.Math.floor(remains / 60000);
var hour = window.Math.floor(min / 60);
var day = window.Math.floor(hour / 24);
min %= 60;
hour %= 24;
if (min !== this.previous_privateServerTime_min) {
this.previous_privateServerTime_min = min;
min = min < 10 ? "0" + min : "" + min;
_this.privateServerTime_img_min = gui_render_text(min, "'Baloo Paaji', sans-serif", "#EFE4B4", 80, 200);
}
if (hour !== this.previous_privateServerTime_hour) {
this.previous_privateServerTime_hour = hour;
hour = hour < 10 ? "0" + hour : "" + hour;
_this.privateServerTime_img_hour = gui_render_text(hour, "'Baloo Paaji', sans-serif", "#EFE4B4", 80, 200);
}
if (day !== this.previous_privateServerTime_day) {
this.previous_privateServerTime_day = day;
day = day < 10 ? "0" + day : "" + day;
_this.privateServerTime_img_day = gui_render_text(day, "'Baloo Paaji', sans-serif", "#EFE4B4", 80, 200);
}
var remain_box = this.bkgd[SERVER_REMAIN_BOX];
remain_box.draw(ctx);
var img = this.privateServerTime_img_day;
ctxDrawImage(ctx, img, remain_box.translate.x - img.width / 4 + 113, remain_box.translate.y - img.height / 4 + 40, img.width / 2, img.height / 2);
var img = this.privateServerTime_img_hour;
ctxDrawImage(ctx, img, remain_box.translate.x - img.width / 4 + 182, remain_box.translate.y - img.height / 4 + 40, img.width / 2, img.height / 2);
var img = this.privateServerTime_img_min;
ctxDrawImage(ctx, img, remain_box.translate.x - img.width / 4 + 251, remain_box.translate.y - img.height / 4 + 40, img.width / 2, img.height / 2);
}
// Select current view for buttons
if ((this.current_view & __GAME__) === __GAME__) this.buttons[GAME_BUTTON].info.state = BUTTON_CLICK;
else if ((this.current_view & __LEADERBOARD__) === __LEADERBOARD__) this.buttons[LEADERBOARD_BUTTON].info.state = BUTTON_CLICK;
else if ((this.current_view & __COSMETICS__) === __COSMETICS__) this.buttons[COSMETICS_BUTTON].info.state = BUTTON_CLICK;
else if ((this.current_view & __PROFILE__) === __PROFILE__) this.buttons[PROFILE_BUTTON].info.state = BUTTON_CLICK;
else if ((this.current_view & __LOGIN__) === __LOGIN__) this.buttons[LOGIN_BUTTON].info.state = BUTTON_CLICK;
else if ((this.current_view & __SHOP__) === __SHOP__) this.buttons[SHOP_BUTTON].info.state = BUTTON_CLICK;
else if ((this.current_view & __SPIN_1__) === __SPIN_1__) this.buttons[SHOP_BUTTON].info.state = BUTTON_CLICK;
else if ((this.current_view & __SPIN_2__) === __SPIN_2__) this.buttons[SHOP_BUTTON].info.state = BUTTON_CLICK;
else if ((this.current_view & __SPIN_3__) === __SPIN_3__) this.buttons[SHOP_BUTTON].info.state = BUTTON_CLICK;
else if ((this.current_view & __SPIN_4__) === __SPIN_4__) this.buttons[SHOP_BUTTON].info.state = BUTTON_CLICK;
else if ((this.current_view & __SPIN_5__) === __SPIN_5__) this.buttons[SHOP_BUTTON].info.state = BUTTON_CLICK;
else if ((this.current_view & __SPIN_6__) === __SPIN_6__) this.buttons[SHOP_BUTTON].info.state = BUTTON_CLICK;
else if ((this.current_view & __SKIN__) === __SKIN__) this.buttons[COSMETICS_BUTTON].info.state = BUTTON_CLICK;
else if ((this.current_view & __BAG__) === __BAG__) this.buttons[COSMETICS_BUTTON].info.state = BUTTON_CLICK;
else if ((this.current_view & __CRATE__) === __CRATE__) this.buttons[COSMETICS_BUTTON].info.state = BUTTON_CLICK;
else if ((this.current_view & __BOOK__) === __BOOK__) this.buttons[COSMETICS_BUTTON].info.state = BUTTON_CLICK;
else if ((this.current_view & __ACCESSORY__) === __ACCESSORY__) this.buttons[COSMETICS_BUTTON].info.state = BUTTON_CLICK;
else if ((this.current_view & __LOOT__) === __LOOT__) this.buttons[COSMETICS_BUTTON].info.state = BUTTON_CLICK;
else if ((this.current_view & __SERVER_DURATION__) === __SERVER_DURATION__) this.buttons[SERVER_BUTTON].info.state = BUTTON_CLICK;
else if ((this.current_view & __SERVER_ACCESS__) === __SERVER_ACCESS__) this.buttons[SERVER_BUTTON].info.state = BUTTON_CLICK;
else if ((this.current_view & __SEASON5__) === __SEASON5__) this.buttons[PROFILE_BUTTON].info.state = BUTTON_CLICK;
// Selected button effect for the leaderboard view
if ((this.current_view & __LEADERBOARD__) === __LEADERBOARD__) {
if (this.leaderboard_mode === this.LEADERBOARD_TOTAL) {
this.leaderboard_range = this.LEADERBOARD_ALL;
this.buttons[this.LEADERBOARD_ALL].info.active = __HIDE__;
this.buttons[this.LEADERBOARD_WEEK].info.active = __HIDE__;
this.buttons[this.LEADERBOARD_TODAY].info.active = __HIDE__;
} else {
this.buttons[this.LEADERBOARD_ALL].info.active = __DISPLAY__;
this.buttons[this.LEADERBOARD_WEEK].info.active = __DISPLAY__;
this.buttons[this.LEADERBOARD_TODAY].info.active = __DISPLAY__;
}
if (this.leaderboard_mode === this.LEADERBOARD_TOTAL) this.buttons[this.LEADERBOARD_TOTAL].info.state = BUTTON_CLICK
// else if (this.leaderboard_mode === this.LEADERBOARD_VAMPIRE) this.buttons[this.LEADERBOARD_VAMPIRE].info.state = BUTTON_CLICK;
else if (this.leaderboard_mode === this.LEADERBOARD_NORMAL) this.buttons[this.LEADERBOARD_NORMAL].info.state = BUTTON_CLICK;
// else if (this.leaderboard_mode === this.LEADERBOARD_ZOMBIE) this.buttons[this.LEADERBOARD_ZOMBIE].info.state = BUTTON_CLICK;
// else if (this.leaderboard_mode === this.LEADERBOARD_FOREST) this.buttons[this.LEADERBOARD_FOREST].info.state = BUTTON_CLICK;
if (this.leaderboard_range === this.LEADERBOARD_ALL) this.buttons[this.LEADERBOARD_ALL].info.state = BUTTON_CLICK;
else if (this.leaderboard_range === this.LEADERBOARD_WEEK) this.buttons[this.LEADERBOARD_WEEK].info.state = BUTTON_CLICK;
else if (this.leaderboard_range === this.LEADERBOARD_TODAY) this.buttons[this.LEADERBOARD_TODAY].info.state = BUTTON_CLICK;
if (this.leaderboard_sorted === this.LEADERBOARD_KILL) this.buttons[this.LEADERBOARD_KILL].info.state = BUTTON_CLICK;
else if (this.leaderboard_sorted === this.LEADERBOARD_SCORE) this.buttons[this.LEADERBOARD_SCORE].info.state = BUTTON_CLICK;
else if (this.leaderboard_sorted === this.LEADERBOARD_TIME) this.buttons[this.LEADERBOARD_TIME].info.state = BUTTON_CLICK;
if (this.leaderboard_season === 0)
this.buttons[this.LEADERBOARD_SEASON1].info.state = BUTTON_CLICK;
}
// Selected button effect for the profile view
if ((this.current_view & __PROFILE__) === __PROFILE__) {
// if (this.current_mode_score === -1) this.buttons[SCORE_MODE_TOTAL].info.state = BUTTON_CLICK;
// else if (this.current_mode_score === WORLD.MODE_PVP) this.buttons[SCORE_MODE_NORMAL].info.state = BUTTON_CLICK;
// else if (this.current_mode_score === WORLD.MODE_ZOMBIES) this.buttons[SCORE_MODE_ZOMBIE].info.state = BUTTON_CLICK;
// else if (this.current_mode_score === WORLD.MODE_VAMPIRES) this.buttons[SCORE_MODE_VAMPIRE].info.state = BUTTON_CLICK;
// else if (this.current_mode_score === WORLD.MODE_LEGACY) this.buttons[SCORE_MODE_FOREST].info.state = BUTTON_CLICK;
if (this.profile_season === 0)
this.buttons[SCORE_MODE_SEASON1].info.state = BUTTON_CLICK;
}
// Update hint effect
if ((this.current_view & __GAME__) === __GAME__ && client.privateServer === 0) {
if (this.buttons[NORMAL_MODE].in_button(mouse.pos)) this.buttons[NORMAL_MODE].hint = window.Math.min(1, this.buttons[NORMAL_MODE].hint + delta * 1.5);
else this.buttons[NORMAL_MODE].hint = window.Math.max(0, this.buttons[NORMAL_MODE].hint - delta * 1.5);
// if (this.buttons[FOREST_MODE].in_button(mouse.pos)) this.buttons[FOREST_MODE].hint = window.Math.min(1, this.buttons[FOREST_MODE].hint + delta * 1.5);
// else this.buttons[FOREST_MODE].hint = window.Math.max(0, this.buttons[FOREST_MODE].hint - delta * 1.5);
if (this.buttons[MODE_COMMUNITY].in_button(mouse.pos)) this.buttons[MODE_COMMUNITY].hint = window.Math.min(1, this.buttons[MODE_COMMUNITY].hint + delta * 1.5);
else this.buttons[MODE_COMMUNITY].hint = window.Math.max(0, this.buttons[MODE_COMMUNITY].hint - delta * 1.5);
if (this.buttons[MODE_EXPERIMENTAL].in_button(mouse.pos)) this.buttons[MODE_EXPERIMENTAL].hint = window.Math.min(1, this.buttons[MODE_EXPERIMENTAL].hint + delta * 1.5);
else this.buttons[MODE_EXPERIMENTAL].hint = window.Math.max(0, this.buttons[MODE_EXPERIMENTAL].hint - delta * 1.5);
// if (this.buttons[ZOMBIE_MODE].in_button(mouse.pos)) this.buttons[ZOMBIE_MODE].hint = window.Math.min(1, this.buttons[ZOMBIE_MODE].hint + delta * 1.5);
// else this.buttons[ZOMBIE_MODE].hint = window.Math.max(0, this.buttons[ZOMBIE_MODE].hint - delta * 1.5);
// if (this.buttons[VAMPIRE_MODE].in_button(mouse.pos)) this.buttons[VAMPIRE_MODE].hint = window.Math.min(1, this.buttons[VAMPIRE_MODE].hint + delta * 1.5);
// else this.buttons[VAMPIRE_MODE].hint = window.Math.max(0, this.buttons[VAMPIRE_MODE].hint - delta * 1.5);
}
// Render spin effect
var _r = 1;
if ((this.current_view & (__SPIN_1__ | __SPIN_2__ | __SPIN_3__ | __SPIN_4__ | __SPIN_5__ | __SPIN_6__)) > 1) {
var img = IMAGES.ARROW_SPIN;
ctx.save();
ctx.translate(canw2, SPIN_TOP + img.height / 4);
if (this.spin === 1) {
this.spin_effect += delta / 3;
_r = this.spin_target - 100 / window.Math.pow(1 + this.spin_effect, 1 + this.spin_effect);
ctx.rotate(_r);
}
ctxDrawImage(ctx, img, -img.width / 4, -img.height / 4, img.width / 2, img.height / 2);
ctx.restore();
}
// Select current mode for buttons
if (client.privateServer === 0) {
if (client.current_mode === WORLD.MODE_PVP) this.buttons[NORMAL_MODE].info.state = BUTTON_CLICK;
// else if (client.current_mode === WORLD.MODE_LEGACY) this.buttons[FOREST_MODE].info.state = BUTTON_CLICK;
// else if (client.current_mode === WORLD.MODE_ZOMBIES) this.buttons[ZOMBIE_MODE].info.state = BUTTON_CLICK;
// else if (client.current_mode === WORLD.MODE_VAMPIRES) this.buttons[VAMPIRE_MODE].info.state = BUTTON_CLICK;
else if (client.current_mode === WORLD.MODE_COMMUNITY) this.buttons[MODE_COMMUNITY].info.state = BUTTON_CLICK;
else if (client.current_mode === WORLD.MODE_EXPERIMENTAL) this.buttons[MODE_EXPERIMENTAL].info.state = BUTTON_CLICK;
}
for (var i = 1; i < this.buttons.length; i++) {
if (this.buttons[i].info.active === __DISPLAY__) this.buttons[i].draw(ctx);
}
// Render top left UI
this.bkgd[0].draw(ctx);
// Render new nickname
if ((this.current_view & (__CHANGE_NICKNAME0__ | __CHANGE_NICKNAME1__)) > 0) {
var img = this.new_nickname_img;
ctxDrawImage(ctx, img, canw2 - img.width / 4, 138, img.width / 2, img.height / 2);
}
// Render level image
var lvl = window.Math.max(1, window.Math.min(18, window.Math.floor((ui.lvl + 3) / 2)));
this.bkgd[lvl].active = __DISPLAY__;
this.bkgd[lvl].draw(ctx);
this.bkgd[lvl].active = __HIDE__;
this.buttons[0].draw(ctx);
// Display cosmetics current selection
if ((this.current_view & (__COSMETICS__ | __BAG__ | __BOOK__ | __SKIN__ | __ACCESSORY__)) > 1) {
var _x = (this.current_view & (__BAG__ | __BOOK__ | __SKIN__ | __ACCESSORY__)) > 1 ? -190 : 0;
var img = sprite[ItemType.BAG][this.bag][this.day_mode];
ctxDrawImage(ctx, img, canw2 - img.width / 4 + _x, 183, img.width / 2, img.height / 2);
this.breath = (this.breath + delta * 1000) % 2000;
var v = 4.5 * (this.breath < 1000) ? this.breath / 1000 : (2000 - this.breath) / 1000;
var img = sprite[ItemType.BOOK][this.book][this.day_mode];
ctxDrawImage(ctx, img, canw2 - img.width / 4 - 62 + v + _x, 240, img.width / 2, img.height / 2);
var img = sprite[ItemType.HAND][this.skin][this.day_mode];
ctxDrawImage(ctx, img, canw2 - img.width / 4 - 54 + v + _x, 272, img.width / 2, img.height / 2);
ctxDrawImage(ctx, img, canw2 - img.width / 4 + 54 - v + _x, 272, img.width / 2, img.height / 2);
var img = sprite[SPRITE.BODY][this.skin][this.day_mode];
ctxDrawImage(ctx, img, canw2 - img.width / 4 + _x, 222, img.width / 2, img.height / 2);
var img = sprite[SPRITE.ACCESSORY][this.accessory][this.day_mode];
ctxDrawImage(ctx, img, canw2 - img.width / 4 + _x, 222, img.width / 2, img.height / 2);
}
// Render crate
if ((this.current_view & __COSMETICS__) === __COSMETICS__) {
var img = sprite[SPRITE.CRATE][this.crate][this.day_mode];
ctxDrawImage(ctx, img, canw2 - img.width / 4 - 61, 406 - img.height / 4, img.width / 2, img.height / 2);
var img = sprite[SPRITE.CRATE][this.dead][this.day_mode];
ctxDrawImage(ctx, img, canw2 - img.width / 4 + 53, 406 - img.height / 4, img.width / 2, img.height / 2);
}
if ((this.current_view & __CRATE__) === __CRATE__) {
var img = sprite[SPRITE.CRATE][this.dead][this.day_mode];
ctxDrawImage(ctx, img, canw2 - img.width / 4 - 200, 268 - img.height / 4, img.width / 2, img.height / 2);
}
if ((this.current_view & __LOOT__) === __LOOT__) {
var img = sprite[SPRITE.CRATE][this.crate][this.day_mode];
ctxDrawImage(ctx, img, canw2 - img.width / 4 - 200, 268 - img.height / 4, img.width / 2, img.height / 2);
}
// Render cosmetics selector
if ((this.current_view & (__BAG__ | __BOOK__ | __SKIN__ | __ACCESSORY__ | __CRATE__ | __LOOT__)) > 1) {
for (var i = 1; i < this.buttons.length; i++) {
if ((this.buttons[i].view & this.current_view) === 0) continue;
var button = this.buttons[i].info;
if (button.cosmeticId >= 0) {
var img = button.cosmeticType[button.cosmeticId].day;
ctxDrawImage(ctx, img, button.translate.x - img.width / 8 + 44.5, button.translate.y - img.height / 8 + 45.5, img.width / 4, img.height / 4);
if (button.unlocked !== 1) {
var img = IMAGES.RED_LOCKED;
ctxDrawImage(ctx, img, button.translate.x - img.width / 4 + 44.5, button.translate.y - img.height / 4 + 44.5, img.width / 2, img.height / 2);
}
}
}
var img = this.cosmetic_name;
ctxDrawImage(ctx, img, canw2 - 312, 375, img.width / 2, img.height / 2);
var img = this.cosmetic_author;
ctxDrawImage(ctx, img, canw2 - 312, 395, img.width / 2, img.height / 2);
}
// Draw text info
if (this.bread !== this.previous_bread) {
this.previous_bread = this.bread;
this.bread_img = gui_render_text("" + this.bread, "'Baloo Paaji', sans-serif", "#EFE4B4", 60, 250);
}
ctxDrawImage(ctx, this.bread_img, this.bkgd[0].translate.x + 350, 15, this.bread_img.w2, this.bread_img.h2);
if (this.lvl !== this.previous_lvl) {
this.previous_lvl = this.lvl;
this.lvl_img = gui_render_text("LVL " + (this.lvl + 1), "'Baloo Paaji', sans-serif", "#EFE4B4", 50, 250, undefined, 30, 24, undefined, undefined, undefined, undefined, "#3F3019", 20);
}
ctxDrawImage(ctx, this.lvl_img, this.bkgd[0].translate.x + 94, 0, this.lvl_img.w2, this.lvl_img.h2);
// Display hint effect
if (client.privateServer === 0) {
var hint = this.buttons[NORMAL_MODE].hint;
if (hint > 0) {
var img = IMAGES.NORMAL_MODE_HOVER;
ctxDrawImage(ctx, img, canw2 - img.width / 4, -36 - (img.height * Utils.ease_in_out_quad(1 - hint)) / 2, img.width / 2, img.height / 2);
}
// var hint = this.buttons[FOREST_MODE].hint;
// if (hint > 0) {
// var img = IMAGES.FOREST_MODE_HOVER;
// ctxDrawImage(ctx, img, canw2 - img.width / 4, -36 - (img.height * Utils.ease_in_out_quad(1 - hint)) / 2, img.width / 2, img.height / 2);
// }
var hint = this.buttons[MODE_COMMUNITY].hint;
if (hint > 0) {
var img = IMAGES.MODE_COMMUNITY_HOVER;
ctxDrawImage(ctx, img, canw2 - img.width / 4, -36 - (img.height * Utils.ease_in_out_quad(1 - hint)) / 2, img.width / 2, img.height / 2);
}
var hint = this.buttons[MODE_EXPERIMENTAL].hint;
if (hint > 0) {
var img = IMAGES.MODE_EXPERIMENTAL_HOVER;
ctxDrawImage(ctx, img, canw2 - img.width / 4, -36 - (img.height * Utils.ease_in_out_quad(1 - hint)) / 2, img.width / 2, img.height / 2);
}
// var hint = this.buttons[VAMPIRE_MODE].hint;
// if (hint > 0) {
// var img = IMAGES.VAMPIRE_MODE_HOVER;
// ctxDrawImage(ctx, img, canw2 - img.width / 4, -36 - (img.height * Utils.ease_in_out_quad(1 - hint)) / 2, img.width / 2, img.height / 2);
// }
// var hint = this.buttons[ZOMBIE_MODE].hint;
// if (hint > 0) {
// var img = IMAGES.ZOMBIE_MODE_HOVER;
// ctxDrawImage(ctx, img, canw2 - img.width / 4, -36 - (img.height * Utils.ease_in_out_quad(1 - hint)) / 2, img.width / 2, img.height / 2);
// }
}
// Spin win effect
if (this.spin === 1 && window.Math.abs(_r - this.spin_target) < 0.006) {
ctx.globalAlpha = window.Math.min(1, this.spin_win_effect * 3);
var img = IMAGES.SPIN_LIGHT;
ctx.save();
ctx.translate(canw2, 260);
this.spin_win_effect += delta;
ctx.rotate(this.spin_win_effect);
ctxDrawImage(ctx, img, -img.width / 2, -img.height / 2, img.width, img.height);
ctx.restore();
var v = 1.05 + 0.05 * window.Math.sin(this.spin_win_effect * 5);
if (this.spin_type === 0) {
var img = COSMETICS.SKIN[this.spin_win].day;
var w = v * img.width;
var h = v * img.height;
ctxDrawImage(ctx, img, canw2 - w / 2, 260 - h / 2, w, h);
} else if (this.spin_type === 1) {
var img = COSMETICS.SKIN[0].day;
var w = v * img.width;
var h = v * img.height;
ctxDrawImage(ctx, img, canw2 - w / 2, 260 - h / 2, w, h);
var img = COSMETICS.ACCESSORY[this.spin_win].day;
var w = v * img.width;
var h = v * img.height;
ctxDrawImage(ctx, img, canw2 - w / 2, 260 - h / 2, w, h);
} else if (this.spin_type === 2) {
var img = COSMETICS.BAG[this.spin_win].day;
var w = v * img.width;
var h = v * img.height;
ctxDrawImage(ctx, img, canw2 - w / 2, 180 - h / 2, w, h);
var img = COSMETICS.SKIN[0].day;
var w = v * img.width;
var h = v * img.height;
ctxDrawImage(ctx, img, canw2 - w / 2, 260 - h / 2, w, h);
} else if (this.spin_type === 3) {
var img = COSMETICS.BOOK[this.spin_win].day;
var w = v * img.width;
var h = v * img.height;
ctx.save();
ctx.translate(canw2, 260);
ctx.rotate(window.Math.PI);
ctxDrawImage(ctx, img, -w / 2, -h / 2, w, h);
ctx.restore();
} else if (this.spin_type === 4) {
var img = COSMETICS.CRATE[this.spin_win].day;
var w = v * img.width;
var h = v * img.height;
ctxDrawImage(ctx, img, canw2 - w / 2, 260 - h / 2, w, h);
}
var img = this.spin_name;
ctxDrawImage(ctx, img, canw2 - img.width / 4, 340, img.width / 2, img.height / 2);
var img = this.spin_author;
ctxDrawImage(ctx, img, canw2 - img.width / 4, 365, img.width / 2, img.height / 2);
if (this.spin_win_effect > 6) {
this.spin = 0;
select_subview(__SHOP__);
}
ctx.globalAlpha = 1;
}
// Draw alert message
user.alert.draw();
/* Loading */
if (_this.waiting) this.loading.draw();
};
var COUNTER = 0;
var __GAME__ = window.Math.pow(2, COUNTER++);
var __PROFILE__ = window.Math.pow(2, COUNTER++);
this.__PROFILE__ = __PROFILE__;
var __LOGIN__ = window.Math.pow(2, COUNTER++);
var __COSMETICS__ = window.Math.pow(2, COUNTER++);
var __SHOP__ = window.Math.pow(2, COUNTER++);
var __LEADERBOARD__ = window.Math.pow(2, COUNTER++);
var __BUY__ = window.Math.pow(2, COUNTER++);
this.__BUY__ = __BUY__;
var __LOCKED_SKIN__ = window.Math.pow(2, COUNTER++);
var __LOCKED_ACC__ = window.Math.pow(2, COUNTER++);
var __SPIN_1__ = window.Math.pow(2, COUNTER++);
var __SPIN_2__ = window.Math.pow(2, COUNTER++);
var __SPIN_3__ = window.Math.pow(2, COUNTER++);
var __SPIN_4__ = window.Math.pow(2, COUNTER++);
var __SPIN_5__ = window.Math.pow(2, COUNTER++);
var __SPIN_6__ = window.Math.pow(2, COUNTER++);
var __SKIN__ = window.Math.pow(2, COUNTER++);
var __CRATE__ = window.Math.pow(2, COUNTER++);
var __BAG__ = window.Math.pow(2, COUNTER++);
var __BOOK__ = window.Math.pow(2, COUNTER++);
var __ACCESSORY__ = window.Math.pow(2, COUNTER++);
var __LOOT__ = window.Math.pow(2, COUNTER++);
var __CHANGE_NICKNAME1__ = window.Math.pow(2, COUNTER++);
var __CHANGE_NICKNAME0__ = window.Math.pow(2, COUNTER++);
var __SERVER_DURATION__ = window.Math.pow(2, COUNTER++);
this.__SERVER_DURATION__ = __SERVER_DURATION__;
var __SERVER_ACCESS__ = window.Math.pow(2, COUNTER++);
this.__SERVER_ACCESS__ = __SERVER_ACCESS__;
var __SEASON5__ = window.Math.pow(2, COUNTER++);
this.current_view = __GAME__;
// Hide or display only one UI type
function update_subview(view, mode, _css) {
// Hide the previous view component
for (var i = 0; i < _this.bkgd.length; i++) {
if ((_this.bkgd[i].view & view) !== 0) _this.bkgd[i].active = mode;
}
for (var i = 0; i < _this.buttons.length; i++) {
if ((_this.buttons[i].view & view) !== 0) _this.buttons[i].info.active = mode;
}
for (var i = 0; i < _this.css.length; i++) {
if ((_this.css[i].view & view) !== 0) _this.css[i].style.display = _css;
}
}
// Correct the selected skin
function correct_selected_skin() {
var ct = window.Number(cookiesManager.get("starve_crate"));
var dd = window.Number(cookiesManager.get("starve_dead"));
var bk = window.Number(cookiesManager.get("starve_book"));
var bg = window.Number(cookiesManager.get("starve_bag"));
var sk = window.Number(cookiesManager.get("starve_skin"));
var ac = window.Number(cookiesManager.get("starve_accessory"));
if (!(ui.unlock.skin[ui.skin] > 0)) ui.skin = !(ui.unlock.skin[sk] > 0) ? 0 : sk;
if (!(ui.unlock.book[ui.book] > 0)) ui.book = !(ui.unlock.book[bk] > 0) ? 0 : bk;
if (!(ui.unlock.dead[ui.dead] > 0)) ui.dead = !(ui.unlock.dead[dd] > 0) ? 0 : dd;
if (!(ui.unlock.crate[ui.crate] > 0)) ui.crate = !(ui.unlock.crate[ct] > 0) ? 0 : ct;
if (!(ui.unlock.accessory[ui.accessory] > 0)) ui.accessory = !(ui.unlock.accessory[ac] > 0) ? 0 : ac;
if (!(ui.unlock.bag[ui.bag] > 0)) ui.bag = !(ui.unlock.bag[bg] > 0) ? 0 : bg;
}
// Move from a UI subview to another
function select_subview(view) {
// Was triggered outside of this view, we don't want that
if (_this.in_this_view === false) return;
// Always hide the popup
update_subview(__LOCKED_SKIN__, __HIDE__, "none");
update_subview(__LOCKED_ACC__, __HIDE__, "none");
// Check the skin integrity
correct_selected_skin();
// We don't need to change the current view for the same view
if (view === _this.current_view || _this.spin >= 1) return;
// Hide or display the ads relatively to the subview
// Hide the previous view component
update_subview(_this.current_view, __HIDE__, "none");
// Display the new view component
_this.current_view = view;
update_subview(_this.current_view, __DISPLAY__, "inline-block");
}
this.select_subview = select_subview;
function play_after() {
/* Fix selected skin */
// showRecaptchaChallenge();
client.connect();
// correct_selected_skin();
// client.connect();
}
this.play_game = function () {
// Prevent multiple connexion
if (_this.waiting === false) {
/* Don't restore session (or even try) */
user.reconnect.enabled = false;
/* User cannot control totally the interface */
_this.waiting = true;
play_after();
}
};
var __LEFT__ = 1;
var __RIGHT__ = 2;
var __TOP__ = 4;
var __BOTTOM__ = 8;
var __MIDDLE_X__ = 16;
var __MIDDLE_Y__ = 32;
var __HD__ = 1;
var __NO_BREATH__ = 0;
var __BREATH__ = 1;
var __HIDE__ = 0;
var __DISPLAY__ = 1;
this.login = {
id: window.document.getElementById("login_block"),
style: window.document.getElementById("login_block").style,
input: window.document.getElementById("login_input"),
input_: window.document.getElementById("password_input"),
up: window.document.getElementById("signup"),
in: window.document.getElementById("login"),
active: __DISPLAY__,
position: __TOP__ | __MIDDLE_X__,
view: __LOGIN__,
translate: { x: 0, y: 0, _x: -200, _y: 100 }
};
if (window.innerWidth < 1300) {
this.recaptcha = {
id: document.getElementById("recaptcha-container"),
style: document.getElementById("recaptcha-container").style,
active: __HIDE__,
position: __TOP__ | __LEFT__,
view: __GAME__,
translate: { x: 0, y: 0, _x: 220, _y: 300 }
};
} else {
this.recaptcha = {
id: document.getElementById("recaptcha-container"),
style: document.getElementById("recaptcha-container").style,
active: __HIDE__,
position: __TOP__ | __MIDDLE_X__,
view: __GAME__,
translate: { x: 0, y: 0, _x: -160, _y: 300 }
};
}
let recaptchaWidgetId = null;
function showRecaptchaChallenge() {
if (recaptchaWidgetId == null) {
recaptchaWidgetId = grecaptcha.render('recaptcha-container', {
'sitekey': '6LfDwy0rAAAAAJiC7ZjjdvlU716K1_Yn1ZFK4T4F',
'callback': onRecaptchaSuccess,
'expired-callback': onRecaptchaExpired,
'size': 'normal'
});
} else {
grecaptcha.reset(recaptchaWidgetId);
}
_this.recaptcha.active = __DISPLAY__;
_this.recaptcha.style.display = 'block';
}
function onRecaptchaSuccess(token) {
_this.recaptchaToken = token;
_this.hideRecaptcha();
client.sendHandshakeOrGetSessions();
}
function hideRecaptcha() {
_this.recaptcha.active = __HIDE__;
_this.recaptcha.style.display = 'none';
}
function onRecaptchaExpired() {
console.log("[WARNING]: Recaptcha is expired");
}
this.hideRecaptcha = hideRecaptcha;
this.showRecaptchaChallenge = showRecaptchaChallenge;
this.isRecaptchaVisible = function() {
return _this.recaptcha.view === __DISPLAY__;
}
/* Nickname input */
if (window.innerWidth < 1300) {
this.nickname = {
id: window.document.getElementById("nickname_block"),
style: window.document.getElementById("nickname_block").style,
input: window.document.getElementById("nickname_input"),
active: __DISPLAY__,
position: __TOP__ | __LEFT__,
view: __GAME__,
translate: { x: 0, y: 0, _x: 200, _y: 184 }
};
} else {
this.nickname = {
id: window.document.getElementById("nickname_block"),
style: window.document.getElementById("nickname_block").style,
input: window.document.getElementById("nickname_input"),
active: __DISPLAY__,
position: __TOP__ | __MIDDLE_X__,
view: __GAME__,
translate: { x: 0, y: 0, _x: -180, _y: 184 }
};
}
this.nickname.id.addEventListener("keyup", function (event) {
event.preventDefault();
if (event.keyCode == 13 && !_this.waiting && !_this.settings) _this.play_game();
});
this.login.in.addEventListener("click", async () => {
if (_this.login.input.value.length < 3) return client.new_alert("Login must have more than 2 characters", "#a60f1b");
if (_this.login.input_.value.length < 6) return client.new_alert("Password must have more than 5 characters", "#a60f1b");
if (_this.login.input.value.length > 16) return client.new_alert("Login must have less than 16 characters", "#a60f1b");
if (_this.login.input_.value.length > 16) return client.new_alert("Password must have less than 16 characters", "#a60f1b");
const response = await fetch("/login", {
method: "POST",
headers: {
"Content-type": "application/json"
},
body: window.JSON.stringify({ login: _this.login.input.value, password: _this.login.input_.value })
});
let body = await response.text();
if (body[0] !== "{") return client.new_alert(body, "#a60f1b");
select_subview(__GAME__);
_this.login_restore_data(window.JSON.parse(body));
user.login = _this.login.input.value;
user.password = _this.login.input_.value;
client.new_alert("Log in account", "#27ba36");
if(remember_checkbox.checked) {
cookiesManager.set("starve_login", user.login);
cookiesManager.set("starve_password", user.password);
}
});
this.login.up.addEventListener("click", async() => {
if(_this.login.input.value.length < 3) return client.new_alert("Login must have more than 2 characters", "#a60f1b");
if(_this.login.input_.value.length < 6) return client.new_alert("Password must have more than 5 characters", "#a60f1b");
if(_this.login.input.value.length > 16) return client.new_alert("Login must have less than 16 characters", "#a60f1b");
if(_this.login.input_.value.length > 16) return client.new_alert("Password must have less than 16 characters", "#a60f1b");
const response = await fetch("/register", {
method: "POST",
headers: {
"Content-type": "application/json"
},
body: window.JSON.stringify({login: _this.login.input.value, password: _this.login.input_.value})
});
let body = await response.text();
if(body[0] !== "{") return client.new_alert(body, "#a60f1b");
select_subview(__GAME__);
_this.login_restore_data(window.JSON.parse(body));
user.login = _this.login.input.value;
user.password = _this.login.input_.value;
client.new_alert("Account successfully registered", "#27ba36");
});
this.nickname.input.value = cookiesManager.get("starve_nickname") ? cookiesManager.get("starve_nickname") : "";
this.account_nickname = {
id: window.document.getElementById("account_nickname_block"),
style: window.document.getElementById("account_nickname_block").style,
input: window.document.getElementById("account_nickname_input"),
active: __HIDE__,
position: __TOP__ | __MIDDLE_X__,
view: __PROFILE__,
translate: { x: 0, y: 0, _x: -122, _y: 110 }
};
/* Server list */
/* Nickname input */
if (window.innerWidth < 1300)
this.server_list = {
id: window.document.getElementById("servselect"),
style: window.document.getElementById("servselect").style,
active: __DISPLAY__,
position: __TOP__ | __LEFT__,
view: __GAME__,
translate: { x: 0, y: 0, _x: 208, _y: 225 }
};
else
this.server_list = {
id: window.document.getElementById("servselect"),
style: window.document.getElementById("servselect").style,
active: __DISPLAY__,
position: __TOP__ | __MIDDLE_X__,
view: __GAME__,
translate: { x: 0, y: 0, _x: -180, _y: 225 }
};
/* leaderboard */
this.leaderboard = {
id: window.document.getElementById("leaderboard"),
style: window.document.getElementById("leaderboard").style,
active: __HIDE__,
position: __TOP__ | __MIDDLE_X__,
view: __LEADERBOARD__,
translate: { x: 0, y: 0, _x: -294.5, _y: 190 }
};
/* Profile Stats */
this.stats_box = {
id: window.document.getElementById("stats_box"),
style: window.document.getElementById("stats_box").style,
active: __HIDE__,
position: __TOP__ | __MIDDLE_X__,
view: __PROFILE__,
translate: { x: 0, y: 0, _x: 125, _y: 187 }
};
/* Daily Quests */ /*
this.daily_quest_box = {
id : window.document.getElementById ("daily_quest_box"),
style : window.document.getElementById ("daily_quest_box").style,
active : __HIDE__,
position : __TOP__ | __MIDDLE_X__,
view : __PROFILE__,
translate : { x : 0, y : 0, _x : -300, _y : 400 },
};*/
/* Server Address Input */
this.serverAddressBlock = {
id: window.document.getElementById("serverAddressBlock"),
style: window.document.getElementById("serverAddressBlock").style,
input: window.document.getElementById("serverAddressInput"),
active: __HIDE__,
position: __TOP__ | __MIDDLE_X__,
view: __SERVER_ACCESS__,
translate: { x: 0, y: 0, _x: -220, _y: 350 }
};
COUNTER = 0;
this.css = [];
this.css[COUNTER++] = this.nickname;
this.css[COUNTER++] = this.login;
this.css[COUNTER++] = this.server_list;
this.css[COUNTER++] = this.leaderboard;
this.css[COUNTER++] = this.account_nickname;
this.css[COUNTER++] = this.stats_box;
this.css[COUNTER++] = this.recaptcha;
/*this.css[COUNTER++] = this.daily_quest_box;*/
this.css[COUNTER++] = this.serverAddressBlock;
COUNTER = 0;
this.bkgd = [];
this.bkgd[COUNTER++] = gui_create_image_hd(IMAGES.AVATAR_RESUME, __DISPLAY__, 0, 0, __LEFT__);
this.bkgd[COUNTER++] = gui_create_image_hd(IMAGES.AVATAR_LVL1, __HIDE__, 0, 0, __LEFT__);
this.bkgd[COUNTER++] = gui_create_image_hd(IMAGES.AVATAR_LVL2, __HIDE__, 0, 0, __LEFT__);
this.bkgd[COUNTER++] = gui_create_image_hd(IMAGES.AVATAR_LVL3, __HIDE__, 0, 0, __LEFT__);
this.bkgd[COUNTER++] = gui_create_image_hd(IMAGES.AVATAR_LVL4, __HIDE__, 0, 0, __LEFT__);
this.bkgd[COUNTER++] = gui_create_image_hd(IMAGES.AVATAR_LVL5, __HIDE__, 0, 0, __LEFT__);
this.bkgd[COUNTER++] = gui_create_image_hd(IMAGES.AVATAR_LVL6, __HIDE__, 0, 0, __LEFT__);
this.bkgd[COUNTER++] = gui_create_image_hd(IMAGES.AVATAR_LVL7, __HIDE__, 0, 0, __LEFT__);
this.bkgd[COUNTER++] = gui_create_image_hd(IMAGES.AVATAR_LVL8, __HIDE__, 0, 0, __LEFT__);
this.bkgd[COUNTER++] = gui_create_image_hd(IMAGES.AVATAR_LVL9, __HIDE__, 0, 0, __LEFT__);
this.bkgd[COUNTER++] = gui_create_image_hd(IMAGES.AVATAR_LVL10, __HIDE__, 0, 0, __LEFT__);
this.bkgd[COUNTER++] = gui_create_image_hd(IMAGES.AVATAR_LVL11, __HIDE__, 0, 0, __LEFT__);
this.bkgd[COUNTER++] = gui_create_image_hd(IMAGES.AVATAR_LVL12, __HIDE__, 0, 0, __LEFT__);
this.bkgd[COUNTER++] = gui_create_image_hd(IMAGES.AVATAR_LVL13, __HIDE__, 0, 0, __LEFT__);
this.bkgd[COUNTER++] = gui_create_image_hd(IMAGES.AVATAR_LVL14, __HIDE__, 0, 0, __LEFT__);
this.bkgd[COUNTER++] = gui_create_image_hd(IMAGES.AVATAR_LVL15, __HIDE__, 0, 0, __LEFT__);
this.bkgd[COUNTER++] = gui_create_image_hd(IMAGES.AVATAR_LVL16, __HIDE__, 0, 0, __LEFT__);
this.bkgd[COUNTER++] = gui_create_image_hd(IMAGES.AVATAR_LVL17, __HIDE__, 0, 0, __LEFT__);
this.bkgd[COUNTER++] = gui_create_image_hd(IMAGES.AVATAR_LVL18, __HIDE__, 0, 0, __LEFT__);
if (window.innerWidth < 1300) this.bkgd[COUNTER] = gui_create_image_hd(IMAGES.LOGO_INTERFACE, __DISPLAY__, 200, 100, __TOP__ | __LEFT__);
else this.bkgd[COUNTER] = gui_create_image_hd(IMAGES.LOGO_INTERFACE, __DISPLAY__, -(/*IMAGES.LOGO_INTERFACE.width*/ 753) / 4, 100, __TOP__ | __MIDDLE_X__);
this.bkgd[COUNTER++].view = __GAME__;
this.bkgd[COUNTER++] = gui_create_image_hd(IMAGES.LINKS_BG, __DISPLAY__, 403, -10, __RIGHT__);
if (window.innerWidth > 1300) {
this.bkgd[COUNTER] = gui_create_image_hd(IMAGES.CHANGELOG_BOX, __DISPLAY__, -(/*IMAGES.CHANGELOG_BOX.width*/ 885) / 4, -(/*IMAGES.CHANGELOG_BOX.height*/ 319) / 2, __BOTTOM__ | __MIDDLE_X__);
this.bkgd[COUNTER++].view = __GAME__;
}
this.bkgd[COUNTER] = gui_create_image_hd(IMAGES.PROFILE_BOX, __HIDE__, -(/*IMAGES.PROFILE_BOX.width*/ 1293) / 4, 100, __TOP__ | __MIDDLE_X__);
this.bkgd[COUNTER++].view = __PROFILE__;
this.bkgd[COUNTER] = gui_create_image_hd(IMAGES.SKINS_BOX, __HIDE__, -(/*IMAGES.SKINS_BOX.width*/ 1425) / 4, 100, __TOP__ | __MIDDLE_X__);
this.bkgd[COUNTER++].view = __COSMETICS__;
// this.bkgd[COUNTER] = gui_create_image_hd(IMAGES.ACCOUNT_BOX, __HIDE__, -(/*IMAGES.ACCOUNT_BOX.width*/ 905) / 4, 50, __TOP__ | __MIDDLE_X__);
// this.bkgd[COUNTER++].view = __LOGIN__;
this.bkgd[COUNTER] = gui_create_image_hd(IMAGES.SHOP_BOX, __HIDE__, -(/*IMAGES.SHOP_BOX.width*/ 1608) / 4, 130, __TOP__ | __MIDDLE_X__);
this.bkgd[COUNTER++].view = __SHOP__;
this.bkgd[COUNTER] = gui_create_image_hd(IMAGES.SERVER_LOCATION_BOX, __HIDE__, -(/*IMAGES.SERVER_LOCATION_BOX.width*/ 1117) / 4, 130, __TOP__ | __MIDDLE_X__);
this.bkgd[COUNTER] = gui_create_image_hd(IMAGES.SERVER_DURATION_BOX, __HIDE__, -(/*IMAGES.SERVER_DURATION_BOX.width*/ 1222) / 4, 130, __TOP__ | __MIDDLE_X__);
this.bkgd[COUNTER++].view = __SERVER_DURATION__;
this.bkgd[COUNTER] = gui_create_image_hd(IMAGES.SERVER_ACCESS_BOX, __HIDE__, -(/*IMAGES.SERVER_ACCESS_BOX.width*/ 1222) / 4, 100, __TOP__ | __MIDDLE_X__);
this.bkgd[COUNTER++].view = __SERVER_ACCESS__;
this.bkgd[COUNTER] = gui_create_image_hd(IMAGES.SEASON5_BOX, __HIDE__, -IMAGES.SEASON5_BOX.width / 4 - 350, -15, __TOP__ | __MIDDLE_X__);
this.bkgd[COUNTER++].view = __SEASON5__;
this.bkgd[COUNTER] = gui_create_image_hd(IMAGES.LEADERBOARD_BOX, __HIDE__, -(/*IMAGES.LEADERBOARD_BOX.width*/ 1226) / 4, 100, __TOP__ | __MIDDLE_X__);
this.bkgd[COUNTER++].view = __LEADERBOARD__;
this.bkgd[COUNTER] = gui_create_image_hd(IMAGES.BUY_BREAD_BOX, __HIDE__, -(/*IMAGES.BUY_BREAD_BOX.width*/ 1381) / 4, 80, __TOP__ | __MIDDLE_X__);
this.bkgd[COUNTER++].view = __BUY__;
this.bkgd[COUNTER] = gui_create_image_hd(IMAGES.SPIN1, __HIDE__, -(/*IMAGES.SPIN1.width*/ 1542) / 4, 150, __TOP__ | __MIDDLE_X__);
this.bkgd[COUNTER++].view = __SPIN_1__;
var DEG = 360 / 100;
var spinImg = this.create_spin([
["#25c5d6", DEG * 3],
["#e2cf27", DEG * 10],
["#afac98", DEG * 30],
["#d88e23", DEG * 57]
]);
this.bkgd[COUNTER] = gui_create_image_hd(spinImg, __HIDE__, -spinImg.width / 4, 178, __TOP__ | __MIDDLE_X__);
this.bkgd[COUNTER++].view = __SPIN_1__;
this.play_spin = function (_target, type, win) {
_this.spin = 1;
_this.spin_effect = 0;
_this.spin_win_effect = 0;
_this.spin_target = _target;
_this.spin_type = type;
var info;
var id = 0;
if (type === 0) {
for (let i = 0; i < COSMETICS.SKIN.length; i++) {
id = i;
if (win === COSMETICS.SKIN[i].id) break;
}
info = COSMETICS.SKIN[id];
_this.unlock.skin[id] = 1;
} else if (type === 1) {
for (let i = 0; i < COSMETICS.ACCESSORY.length; i++) {
id = i;
if (win === COSMETICS.ACCESSORY[i].id) break;
}
info = COSMETICS.ACCESSORY[id];
_this.unlock.accessory[id] = 1;
} else if (type === 2) {
for (let i = 0; i < COSMETICS.BAG.length; i++) {
id = i;
if (win === COSMETICS.BAG[i].id) break;
}
info = COSMETICS.BAG[id];
_this.unlock.bag[id] = 1;
} else if (type === 3) {
for (let i = 0; i < COSMETICS.BOOK.length; i++) {
id = i;
if (win === COSMETICS.BOOK[i].id) break;
}
info = COSMETICS.BOOK[id];
_this.unlock.book[id] = 1;
} else if (type === 4) {
for (let i = 0; i < COSMETICS.CRATE.length; i++) {
id = i;
if (win === COSMETICS.CRATE[i].id) break;
}
info = COSMETICS.CRATE[id];
_this.unlock.crate[id] = 1;
_this.unlock.dead[id] = 1;
}
_this.spin_win = id;
_this.spin_author = gui_render_text("by " + info.author, "'Baloo Paaji', sans-serif", "#EFE4B4", 40, 500, undefined, 30, 24, undefined, undefined, undefined, undefined, "#000000", 24);
_this.spin_name = gui_render_text(info.name, "'Baloo Paaji', sans-serif", "#EFE4B4", 60, 600, undefined, 30, 24, undefined, undefined, undefined, undefined, "#000000", 20);
};
this.spin = 0;
this.spin_effect = 0;
this.spin_target = 0;
this.spin_type = 0;
this.spin_win_effect = 0;
this.spin_author = undefined;
this.spin_name = undefined;
var SPIN_TOP = 150 + /*IMAGES.SPIN1.height*/ 448 / 4 - /*IMAGES.ARROW_SPIN.height*/ 260 / 4;
this.bkgd[COUNTER] = gui_create_image_hd(IMAGES.SPIN2, __HIDE__, -(/*IMAGES.SPIN1.width*/ 1542) / 4, 150, __TOP__ | __MIDDLE_X__);
this.bkgd[COUNTER++].view = __SPIN_5__;
var spinImg = this.create_spin([
["#d45ce5", DEG * 3],
["#25c5d6", DEG * 10],
["#e2cf27", DEG * 30],
["#afac98", DEG * 57]
]);
this.bkgd[COUNTER] = gui_create_image_hd(spinImg, __HIDE__, -spinImg.width / 4, 178, __TOP__ | __MIDDLE_X__);
this.bkgd[COUNTER++].view = __SPIN_5__;
this.bkgd[COUNTER] = gui_create_image_hd(IMAGES.SPIN3, __HIDE__, -(/*IMAGES.SPIN1.width*/ 1542) / 4, 150, __TOP__ | __MIDDLE_X__);
this.bkgd[COUNTER++].view = __SPIN_3__;
var spinImg = this.create_spin([
["#d33a2a", DEG * 3],
["#d45ce5", DEG * 10],
["#25c5d6", DEG * 30],
["#e2cf27", DEG * 57]
]);
this.bkgd[COUNTER] = gui_create_image_hd(spinImg, __HIDE__, -spinImg.width / 4, 178, __TOP__ | __MIDDLE_X__);
this.bkgd[COUNTER++].view = __SPIN_3__;
this.bkgd[COUNTER] = gui_create_image_hd(IMAGES.SPIN4, __HIDE__, -(/*IMAGES.SPIN1.width*/ 1542) / 4, 150, __TOP__ | __MIDDLE_X__);
this.bkgd[COUNTER++].view = __SPIN_4__;
var spinImg = this.create_spin([
["#25c5d6", DEG * 3],
["#e2cf27", DEG * 10],
["#afac98", DEG * 30],
["#d88e23", DEG * 57]
]);
this.bkgd[COUNTER] = gui_create_image_hd(spinImg, __HIDE__, -spinImg.width / 4, 178, __TOP__ | __MIDDLE_X__);
this.bkgd[COUNTER++].view = __SPIN_4__;
this.bkgd[COUNTER] = gui_create_image_hd(IMAGES.SPIN5, __HIDE__, -(/*IMAGES.SPIN1.width*/ 1542) / 4, 150, __TOP__ | __MIDDLE_X__);
this.bkgd[COUNTER++].view = __SPIN_2__;
var spinImg = this.create_spin([
["#d45ce5", DEG * 3],
["#25c5d6", DEG * 10],
["#e2cf27", DEG * 30],
["#afac98", DEG * 57]
]);
this.bkgd[COUNTER] = gui_create_image_hd(spinImg, __HIDE__, -spinImg.width / 4, 178, __TOP__ | __MIDDLE_X__);
this.bkgd[COUNTER++].view = __SPIN_2__;
this.bkgd[COUNTER] = gui_create_image_hd(IMAGES.SPIN6, __HIDE__, -(/*IMAGES.SPIN1.width*/ 1542) / 4, 150, __TOP__ | __MIDDLE_X__);
this.bkgd[COUNTER++].view = __SPIN_6__;
var spinImg = this.create_spin([
["#d33a2a", DEG * 3],
["#d45ce5", DEG * 10],
["#25c5d6", DEG * 30],
["#e2cf27", DEG * 57]
]);
this.bkgd[COUNTER] = gui_create_image_hd(spinImg, __HIDE__, -spinImg.width / 4, 178, __TOP__ | __MIDDLE_X__);
this.bkgd[COUNTER++].view = __SPIN_6__;
this.bkgd[COUNTER] = gui_create_image_hd(IMAGES.CUSTOM_SKIN_BOX, __HIDE__, -(/*IMAGES.CUSTOM_SKIN_BOX.width*/ 1366) / 4, 100, __TOP__ | __MIDDLE_X__);
this.bkgd[COUNTER++].view = __SKIN__;
this.bkgd[COUNTER] = gui_create_image_hd(IMAGES.ACCESSORIES_BOX, __HIDE__, -(/*IMAGES.ACCESSORIES_BOX.width*/ 1366) / 4, 100, __TOP__ | __MIDDLE_X__);
this.bkgd[COUNTER++].view = __ACCESSORY__;
this.bkgd[COUNTER] = gui_create_image_hd(IMAGES.BAG_BOX, __HIDE__, -(/*IMAGES.BAG_BOX.width*/ 1366) / 4, 100, __TOP__ | __MIDDLE_X__);
this.bkgd[COUNTER++].view = __BAG__;
this.bkgd[COUNTER] = gui_create_image_hd(IMAGES.BOOK_BOX, __HIDE__, -(/*IMAGES.BOOK_BOX.width*/ 1366) / 4, 100, __TOP__ | __MIDDLE_X__);
this.bkgd[COUNTER++].view = __BOOK__;
this.bkgd[COUNTER] = gui_create_image_hd(IMAGES.CRATE_BOX, __HIDE__, -(/*IMAGES.CRATE_BOX.width*/ 1366) / 4, 100, __TOP__ | __MIDDLE_X__);
this.bkgd[COUNTER++].view = __CRATE__;
this.bkgd[COUNTER] = gui_create_image_hd(IMAGES.LOOT_BOX, __HIDE__, -(/*IMAGES.LOOT_BOX.width*/ 1366) / 4, 100, __TOP__ | __MIDDLE_X__);
this.bkgd[COUNTER++].view = __LOOT__;
var BAG_REMAIN_BOX = COUNTER++;
this.bkgd[BAG_REMAIN_BOX] = gui_create_image_hd(IMAGES.BAG_REMAIN_BOX, __HIDE__, /*IMAGES.AVATAR_RESUME.width*/ 908 / 2 + 30, 0, __TOP__);
var SERVER_REMAIN_BOX = COUNTER++;
this.bkgd[SERVER_REMAIN_BOX] = gui_create_image_hd(IMAGES.SERVER_REMAIN_BOX, __HIDE__, /*IMAGES.AVATAR_RESUME.width*/ 908 / 2 + /*IMAGES.BAG_REMAIN_BOX.width*/ 597 / 2 + 60, 0, __TOP__);
this.bkgd[COUNTER] = gui_create_image_hd(IMAGES.LOCKED_CUSTOM_ALERT, __HIDE__, -(/*IMAGES.LOCKED_CUSTOM_ALERT.width*/ 758) / 4, -5, __TOP__ | __MIDDLE_X__);
this.bkgd[COUNTER++].view = __LOCKED_ACC__;
this.bkgd[COUNTER] = gui_create_image_hd(IMAGES.LOCKED_SKIN_ALERT, __HIDE__, -(/*IMAGES.LOCKED_SKIN_ALERT.width*/ 758) / 4, -5, __TOP__ | __MIDDLE_X__);
this.bkgd[COUNTER++].view = __LOCKED_SKIN__;
var LEVEL_GAUGE = COUNTER++;
this.bkgd[LEVEL_GAUGE] = gui_create_image_hd(IMAGES.GAUGE, __DISPLAY__, 93, 30, __TOP__);
/*
this.bkgd[COUNTER] = gui_create_image_hd (IMAGES.LEADERBOARD_SOON, __HIDE__,
-IMAGES.LEADERBOARD_SOON.width / 4, 110, __TOP__ | __MIDDLE_X__);
this.bkgd[COUNTER++].view = __LEADERBOARD__;
*/
this.bkgd[COUNTER] = gui_create_image_hd(IMAGES.CHANGE_NICKNAME1_BOX, __HIDE__, -(/*IMAGES.CHANGE_NICKNAME1_BOX.width*/ 692) / 4, 110, __TOP__ | __MIDDLE_X__);
this.bkgd[COUNTER++].view = __CHANGE_NICKNAME1__;
this.bkgd[COUNTER] = gui_create_image_hd(IMAGES.CHANGE_NICKNAME0_BOX, __HIDE__, -(/*IMAGES.CHANGE_NICKNAME0_BOX.width*/ 692) / 4, 110, __TOP__ | __MIDDLE_X__);
this.bkgd[COUNTER++].view = __CHANGE_NICKNAME0__;
COUNTER = 0;
this.buttons = [];
// Buy Bread
this.buttons[COUNTER] = gui_create_button(
50,
57,
"",
[IMAGES.BUY_BREAD_OUT, IMAGES.BUY_BREAD_IN, IMAGES.BUY_BREAD_CLICK],
__HD__,
__NO_BREATH__,
function () {
if (_this.isUserLogged()) select_subview(__BUY__);
else select_subview(__LOGIN__);
},
320,
0,
__LEFT__,
__DISPLAY__
);
// Play Game
COUNTER++;
if (window.innerWidth < 1300) this.buttons[COUNTER] = gui_create_button(202, 97, "", [IMAGES.PLAY_BUTTON_OUT, IMAGES.PLAY_BUTTON_IN, IMAGES.PLAY_BUTTON_CLICK], __HD__, __NO_BREATH__, this.play_game, 462, 235, __TOP__ | __LEFT__, __DISPLAY__);
else this.buttons[COUNTER] = gui_create_button(202, 97, "", [IMAGES.PLAY_BUTTON_OUT, IMAGES.PLAY_BUTTON_IN, IMAGES.PLAY_BUTTON_CLICK], __HD__, __NO_BREATH__, this.play_game, 74, 235, __TOP__ | __MIDDLE_X__, __DISPLAY__);
this.buttons[COUNTER].view = __GAME__;
// Changelog
COUNTER++;
if (window.innerWidth > 1300) {
this.buttons[COUNTER] = gui_create_button(
355,
168,
"",
[IMAGES.CHANGELOG_BUTTON_OUT, IMAGES.CHANGELOG_BUTTON_OUT, IMAGES.CHANGELOG_BUTTON_OUT],
__HD__,
__NO_BREATH__,
function () {
window.open("./changelog.html", "_blank");
},
-195,
-115,
__BOTTOM__ | __MIDDLE_X__,
__DISPLAY__
);
this.buttons[COUNTER++].view = __GAME__;
}
this.buttons[COUNTER++] = gui_create_button(
80,
80,
"",
[IMAGES.DISCORD_BUTTON_OUT, IMAGES.DISCORD_BUTTON_IN, IMAGES.DISCORD_BUTTON_CLICK],
__HD__,
__NO_BREATH__,
function () {
window.open("https://discord.gg/nostarve", "_blank");
},
60,
10,
__RIGHT__,
__DISPLAY__
);
// Leaderboard
var LEADERBOARD_BUTTON = COUNTER++;
this.buttons[LEADERBOARD_BUTTON] = gui_create_button(
232,
142,
"",
[IMAGES.ICONS_BOTTOM_BG_BUTTON_OUT, IMAGES.ICONS_BOTTOM_BG_BUTTON_IN, IMAGES.ICONS_BOTTOM_BG_BUTTON_CLICK],
__HD__,
__NO_BREATH__,
function () {
select_subview(__LEADERBOARD__);
getLeaderboard(ui.LEADERBOARD_ALL, ui.LEADERBOARD_TOTAL, ui.LEADERBOARD_SCORE, ui.LEADERBOARD_SEASON5);
},
-5,
494,
__LEFT__,
__DISPLAY__
);
this.buttons[COUNTER++] = gui_create_button(
236,
165,
"",
[IMAGES.LEADERBOARD_ICON, IMAGES.LEADERBOARD_ICON, IMAGES.LEADERBOARD_ICON],
__HD__,
__BREATH__,
function () {
select_subview(__LEADERBOARD__);
},
-5,
494,
__LEFT__,
__DISPLAY__
);
// Server access
// Shop
var SHOP_BUTTON = COUNTER++;
this.buttons[SHOP_BUTTON] = gui_create_button(
236,
165,
"",
[IMAGES.ICONS_BG_BUTTON_OUT, IMAGES.ICONS_BG_BUTTON_IN, IMAGES.ICONS_BG_BUTTON_CLICK],
__HD__,
__NO_BREATH__,
function () {
select_subview(__SHOP__);
},
-5,
336,
__LEFT__,
__DISPLAY__
);
this.buttons[COUNTER++] = gui_create_button(
236,
165,
"",
[IMAGES.SHOP_ICON, IMAGES.SHOP_ICON, IMAGES.SHOP_ICON],
__HD__,
__BREATH__,
function () {
select_subview(__SHOP__);
},
-5,
336,
__LEFT__,
__DISPLAY__
);
// Cosmetic
var COSMETICS_BUTTON = COUNTER++;
this.buttons[COSMETICS_BUTTON] = gui_create_button(
236,
165,
"",
[IMAGES.ICONS_BG_BUTTON_OUT, IMAGES.ICONS_BG_BUTTON_IN, IMAGES.ICONS_BG_BUTTON_CLICK],
__HD__,
__NO_BREATH__,
function () {
select_subview(__COSMETICS__);
},
-5,
257,
__LEFT__,
__DISPLAY__
);
this.buttons[COUNTER++] = gui_create_button(
236,
165,
"",
[IMAGES.SKINS_ICON, IMAGES.SKINS_ICON, IMAGES.SKINS_ICON],
__HD__,
__BREATH__,
function () {
select_subview(__COSMETICS__);
},
-5,
257,
__LEFT__,
__DISPLAY__
);
// Play game
var GAME_BUTTON = COUNTER++;
this.buttons[GAME_BUTTON] = gui_create_button(
236,
165,
"",
[IMAGES.ICONS_BG_BUTTON_OUT, IMAGES.ICONS_BG_BUTTON_IN, IMAGES.ICONS_BG_BUTTON_CLICK],
__HD__,
__NO_BREATH__,
function () {
select_subview(__GAME__);
},
-5,
178,
__LEFT__,
__DISPLAY__
);
this.buttons[COUNTER++] = gui_create_button(
236,
165,
"",
[IMAGES.START_ICON, IMAGES.START_ICON, IMAGES.START_ICON],
__HD__,
__BREATH__,
function () {
select_subview(__GAME__);
},
-5,
178,
__LEFT__,
__DISPLAY__
);
// Login
var LOGIN_BUTTON = COUNTER++;
this.LOGIN_BUTTON = LOGIN_BUTTON;
this.buttons[LOGIN_BUTTON] = gui_create_button(
324,
222,
"",
[IMAGES.LOGIN_BUTTON_OUT, IMAGES.LOGIN_BUTTON_IN, IMAGES.LOGIN_BUTTON_CLICK],
__HD__,
__NO_BREATH__,
function () {
select_subview(__LOGIN__);
},
0,
70,
__LEFT__,
__DISPLAY__
);
// Profile
var PROFILE_BUTTON = COUNTER++;
var PROFILE_BUTTON_2 = COUNTER++;
this.PROFILE_BUTTON = PROFILE_BUTTON;
this.PROFILE_BUTTON_2 = PROFILE_BUTTON_2;
this.buttons[PROFILE_BUTTON] = gui_create_button(
324,
222,
"",
[IMAGES.PROFILE_BUTTON_OUT, IMAGES.PROFILE_BUTTON_IN, IMAGES.PROFILE_BUTTON_CLICK],
__HD__,
__NO_BREATH__,
function () {
select_subview(__PROFILE__);
init_profile(-1);
},
0,
70,
__LEFT__,
__HIDE__
);
this.buttons[PROFILE_BUTTON_2] = gui_create_button(
324,
222,
"",
[IMAGES.PROFILE_ICON, IMAGES.PROFILE_ICON, IMAGES.PROFILE_ICON],
__HD__,
__BREATH__,
function () {
select_subview(__PROFILE__);
init_profile(-1);
},
0,
70,
__LEFT__,
__HIDE__
);
// Do not display mode selection if the player use private server to play the game
if (client.privateServer === 0) {
var NORMAL_MODE = COUNTER++;
if (window.innerWidth < 1300)
this.buttons[NORMAL_MODE] = gui_create_button(
266,
176,
"",
[IMAGES.NORMAL_MODE_OUT, IMAGES.NORMAL_MODE_IN, IMAGES.NORMAL_MODE_CLICK],
__HD__,
__NO_BREATH__,
function () {
client.select_gamemode(WORLD.MODE_PVP);
},
150,
300,
__LEFT__ | __TOP__,
__DISPLAY__
);
else
this.buttons[NORMAL_MODE] = gui_create_button(
266,
176,
"",
[IMAGES.NORMAL_MODE_OUT, IMAGES.NORMAL_MODE_IN, IMAGES.NORMAL_MODE_CLICK],
__HD__,
__NO_BREATH__,
function () {
client.select_gamemode(WORLD.MODE_PVP);
},
-200,// -340,
300,//100,
__MIDDLE_X__ | __TOP__,
__DISPLAY__
);
this.buttons[NORMAL_MODE].view = __GAME__;
this.buttons[NORMAL_MODE].hint = 0;
this.buttons[NORMAL_MODE].info.translate._oldx = this.buttons[NORMAL_MODE].info.translate.x;
this.buttons[NORMAL_MODE].info.translate._oldy = this.buttons[NORMAL_MODE].info.translate.y;
// var FOREST_MODE = COUNTER++;
// if (window.innerWidth < 1300)
// this.buttons[FOREST_MODE] = gui_create_button(
// 266,
// 176,
// "",
// [IMAGES.FOREST_MODE_OUT, IMAGES.FOREST_MODE_IN, IMAGES.FOREST_MODE_CLICK],
// __HD__,
// __NO_BREATH__,
// function () {
// client.select_gamemode(WORLD.MODE_LEGACY);
// },
// 150,
// 400,
// __LEFT__ | __TOP__,
// __DISPLAY__
// );
// else
// this.buttons[FOREST_MODE] = gui_create_button(
// 266,
// 176,
// "",
// [IMAGES.FOREST_MODE_OUT, IMAGES.FOREST_MODE_IN, IMAGES.FOREST_MODE_CLICK],
// __HD__,
// __NO_BREATH__,
// function () {
// client.select_gamemode(WORLD.MODE_LEGACY);
// },
// -340,
// 200,
// __MIDDLE_X__ | __TOP__,
// __DISPLAY__
// );
// this.buttons[FOREST_MODE].view = __GAME__;
// this.buttons[FOREST_MODE].hint = 0;
var MODE_COMMUNITY = COUNTER++;
if (window.innerWidth < 1300)
this.buttons[MODE_COMMUNITY] = gui_create_button(
266,
176,
"",
[IMAGES.MODE_COMMUNITY_OUT, IMAGES.MODE_COMMUNITY_IN, IMAGES.MODE_COMMUNITY_CLICK],
__HD__,
__NO_BREATH__,
function () {
client.select_gamemode(WORLD.MODE_COMMUNITY);
},
450,
300,
__LEFT__ | __TOP__,
__DISPLAY__
);
else
this.buttons[MODE_COMMUNITY] = gui_create_button(
266,
176,
"",
[IMAGES.MODE_COMMUNITY_OUT, IMAGES.MODE_COMMUNITY_IN, IMAGES.MODE_COMMUNITY_CLICK],
__HD__,
__NO_BREATH__,
function () {
client.select_gamemode(WORLD.MODE_COMMUNITY);
},
-60,// -340,
300,
__MIDDLE_X__ | __TOP__,
__DISPLAY__
);
this.buttons[MODE_COMMUNITY].view = __GAME__;
this.buttons[MODE_COMMUNITY].hint = 0;
this.buttons[MODE_COMMUNITY].info.translate._oldx = this.buttons[MODE_COMMUNITY].info.translate.x;
this.buttons[MODE_COMMUNITY].info.translate._oldy = this.buttons[MODE_COMMUNITY].info.translate.y;
// var ZOMBIE_MODE = COUNTER++;
// if (window.innerWidth < 1300)
// this.buttons[ZOMBIE_MODE] = gui_create_button(
// 266,
// 176,
// "",
// [IMAGES.ZOMBIE_MODE_OUT, IMAGES.ZOMBIE_MODE_IN, IMAGES.ZOMBIE_MODE_CLICK],
// __HD__,
// __NO_BREATH__,
// function () {
// client.select_gamemode(WORLD.MODE_ZOMBIES);
// },
// 300,
// 300,
// __LEFT__ | __TOP__,
// __DISPLAY__
// );
// else
// this.buttons[ZOMBIE_MODE] = gui_create_button(
// 266,
// 176,
// "",
// [IMAGES.ZOMBIE_MODE_OUT, IMAGES.ZOMBIE_MODE_IN, IMAGES.ZOMBIE_MODE_CLICK],
// __HD__,
// __NO_BREATH__,
// function () {
// client.select_gamemode(WORLD.MODE_ZOMBIES);
// },
// 204,
// 100,
// __MIDDLE_X__ | __TOP__,
// __DISPLAY__
// );
// this.buttons[ZOMBIE_MODE].view = __GAME__;
// this.buttons[ZOMBIE_MODE].hint = 0;
// var VAMPIRE_MODE = COUNTER++;
// if (window.innerWidth < 1300)
// this.buttons[VAMPIRE_MODE] = gui_create_button(
// 266,
// 176,
// "",
// [IMAGES.VAMPIRE_MODE_OUT, IMAGES.VAMPIRE_MODE_IN, IMAGES.VAMPIRE_MODE_CLICK],
// __HD__,
// __NO_BREATH__,
// function () {
// client.select_gamemode(WORLD.MODE_VAMPIRES);
// },
// 300,
// 400,
// __LEFT__ | __TOP__,
// __DISPLAY__
// );
// else
// this.buttons[VAMPIRE_MODE] = gui_create_button(
// 266,
// 176,
// "",
// [IMAGES.VAMPIRE_MODE_OUT, IMAGES.VAMPIRE_MODE_IN, IMAGES.VAMPIRE_MODE_CLICK],
// __HD__,
// __NO_BREATH__,
// function () {
// client.select_gamemode(WORLD.MODE_VAMPIRES);
// },
// 204,
// 200,
// __MIDDLE_X__ | __TOP__,
// __DISPLAY__
// );
// this.buttons[VAMPIRE_MODE].view = __GAME__;
// this.buttons[VAMPIRE_MODE].hint = 0;
// Experimental
var MODE_EXPERIMENTAL = COUNTER++;
this.buttons[MODE_EXPERIMENTAL] = gui_create_button(
266,
176,
"",
[IMAGES.MODE_EXPERIMENTAL_OUT, IMAGES.MODE_EXPERIMENTAL_IN, IMAGES.MODE_EXPERIMENTAL_CLICK],
__HD__,
__NO_BREATH__,
function () {
client.select_gamemode(WORLD.MODE_EXPERIMENTAL);
},
window.innerWidth < 1300 ? 450 : 80,//204,
window.innerWidth < 1300 ? 400 : 300,
(window.innerWidth < 1300 ? __LEFT__ : __MIDDLE_X__) | __TOP__,
__DISPLAY__
);
this.buttons[MODE_EXPERIMENTAL].view = __GAME__;
this.buttons[MODE_EXPERIMENTAL].hint = 0;
this.buttons[MODE_EXPERIMENTAL].info.translate._oldx = this.buttons[MODE_EXPERIMENTAL].info.translate.x;
this.buttons[MODE_EXPERIMENTAL].info.translate._oldy = this.buttons[MODE_EXPERIMENTAL].info.translate.y;
}
//Modify Profile
this.buttons[COUNTER] = gui_create_button(
87,
78,
"",
[IMAGES.MODIFY_NAME_OUT, IMAGES.MODIFY_NAME_IN, IMAGES.MODIFY_NAME_CLICK],
__HD__,
__NO_BREATH__,
function () {
ui.generate_new_nickname();
if (ui.firstName === 0) select_subview(__CHANGE_NICKNAME0__);
else select_subview(__CHANGE_NICKNAME1__);
},
127,
110,
__MIDDLE_X__ | __TOP__,
__HIDE__
);
this.buttons[COUNTER++].view = __PROFILE__;
//Log out Profile
this.buttons[COUNTER] = gui_create_button(
87,
78,
"",
[IMAGES.LOGOUT_OUT, IMAGES.LOGOUT_IN, IMAGES.LOGOUT_CLICK],
__HD__,
__NO_BREATH__,
function () {
logout();
},
255,
110,
__MIDDLE_X__ | __TOP__,
__HIDE__
);
this.buttons[COUNTER++].view = __PROFILE__;
// Close Box
// this.buttons[COUNTER] = gui_create_button(
// 58,
// 64,
// "",
// [IMAGES.CLOSE_BUTTON_OUT, IMAGES.CLOSE_BUTTON_IN, IMAGES.CLOSE_BUTTON_CLICK],
// __HD__,
// __NO_BREATH__,
// function () {
// select_subview(__GAME__);
// },
// 189,
// 118,
// __MIDDLE_X__ | __TOP__,
// __HIDE__
// );
// this.buttons[COUNTER++].view = __LOGIN__;
// Login Google
// this.buttons[COUNTER] = gui_create_button(
// 497,
// 72,
// "",
// [IMAGES.LOGIN_GOOGLE_OUT, IMAGES.LOGIN_GOOGLE_IN, IMAGES.LOGIN_GOOGLE_CLICK],
// __HD__,
// __NO_BREATH__,
// function () {
// loginWithGoogle();
// },
// -130,
// 390,
// __MIDDLE_X__ | __TOP__,
// __HIDE__
// );
// this.buttons[COUNTER++].view = __LOGIN__;
var __LEVEL_FACTOR__ = 20000;
function xp_formula(score) {
var lvl = ui.level_formula(score);
var previous_exp = lvl * lvl * __LEVEL_FACTOR__;
var next_exp = (lvl + 1) * (lvl + 1) * __LEVEL_FACTOR__ - previous_exp;
score -= previous_exp;
return score / next_exp;
}
this.xp_formula = xp_formula;
function level_formula(score) {
return window.Math.floor(window.Math.sqrt(score / __LEVEL_FACTOR__));
}
this.level_formula = level_formula;
this.update_score = function (score) {
ui.lvl = ui.level_formula(score);
ui.xp_dest = ui.xp_formula(score);
ui.xp = 0;
ui.score = score;
};
function init_profile(id, season) {
// Change season stats
if (season !== undefined) {
ui.profile_season = season;
var lastSeason = ui.seasons[season];
ui.score = lastSeason["score"];
ui.kill = lastSeason["kill"];
ui.death = lastSeason["death"];
ui.time = lastSeason["time"];
ui.bestScore = lastSeason["bestScore"];
ui.bestKill = lastSeason["bestKill"];
ui.bestTime = lastSeason["bestTime"];
ui.scoreTotal = lastSeason["scoreTotal"];
}
// Reset id with the previous value if not defined
if (id === undefined) id = ui.current_mode_score;
if (id === undefined || id === -1) id = 0;
ui.current_mode_score = id;
// if (id >= 0) {
// window.document.getElementById("stats_box_time").innerHTML = ui.bestTime[id];
// window.document.getElementById("stats_box_kill").innerHTML = ui.bestKill[id];
// window.document.getElementById("stats_box_score").innerHTML = ui.bestScore[id];
// }
if (id <= 0) {
window.document.getElementById("stats_box_time").innerHTML = ui.time;
window.document.getElementById("stats_box_kill").innerHTML = ui.kill;
window.document.getElementById("stats_box_score").innerHTML = ui.score;
}
}
this.login_restore_data = function (data) {
ui.buttons[ui.LOGIN_BUTTON].info.active = 0;
ui.buttons[ui.PROFILE_BUTTON].info.active = 1;
ui.buttons[ui.PROFILE_BUTTON_2].info.active = 1;
init_skin();
if (data["name"].indexOf("Starver#") === -1) window.document.getElementById("account_nickname_input").value = data["name"];
else window.document.getElementById("account_nickname_input").value = data["name"];
ui.bread = data["bread"];
var seasons = data["seasons"];
var lastSeason = seasons[seasons.length - 1];
ui.seasons = seasons;
_this.update_score(lastSeason["score"]);
ui.score = lastSeason["score"];
ui.kill = lastSeason["kill"];
ui.death = lastSeason["death"];
ui.time = lastSeason["time"];
ui.bestScore = lastSeason["bestScore"];
ui.bestKill = lastSeason["bestKill"];
ui.bestTime = lastSeason["bestTime"];
ui.scoreTotal = lastSeason["scoreTotal"];
ui.firstName = data["firstName"];
window.document.getElementById("serverAddressInput").value = DB + "?server=" + data["privateServer"];
if (ui.firstName === undefined) ui.firstName = 0;
ui.privateServerTime = Date.now() + data["privateServerTime"];
if (window.Number(data["privateServerTime"]) > 0) ui.privateServerTime = Date.now() + window.Number(data["privateServerTime"]);
ui.kit = Date.now() + data["kit"];
if (window.Number(data["kit"]) > 0) ui.kit = Date.now() + window.Number(data["kit"]);
var cosmetic = COSMETICS.SKIN;
for (var i = 0; i < data["skins"].length; i++) {
var v = data["skins"][i];
if (v > 0) {
for (var j = 0; j < cosmetic.length; j++) {
if (cosmetic[j].id === i) _this.unlock.skin[j] = 1;
}
}
}
var cosmetic = COSMETICS.ACCESSORY;
for (var i = 0; i < data["accessories"].length; i++) {
var v = data["accessories"][i];
if (v > 0) {
for (var j = 0; j < cosmetic.length; j++) {
if (cosmetic[j].id === i) _this.unlock.accessory[j] = 1;
}
}
}
var cosmetic = COSMETICS.BOOK;
for (var i = 0; i < data["books"].length; i++) {
var v = data["books"][i];
if (v > 0) {
for (var j = 0; j < cosmetic.length; j++) {
if (cosmetic[j].id === i) _this.unlock.book[j] = 1;
}
}
}
var cosmetic = COSMETICS.BAG;
for (var i = 0; i < data["bags"].length; i++) {
var v = data["bags"][i];
if (v > 0) {
for (var j = 0; j < cosmetic.length; j++) {
if (cosmetic[j].id === i) _this.unlock.bag[j] = 1;
}
}
}
var cosmetic = COSMETICS.CRATE;
for (var i = 0; i < data["crates"].length; i++) {
var v = data["crates"][i];
if (v > 0) {
for (var j = 0; j < cosmetic.length; j++) {
if (cosmetic[j].id === i) {
_this.unlock.crate[j] = 1;
_this.unlock.dead[j] = 1;
}
}
}
}
};
this.login_after = function () {
window.onUserLogin = function () {
select_subview(__GAME__);
getUserDetails(_this.login_restore_data);
};
// If the user logged in during the loading time
if (userAlreadyLoggedIn === 1) window.onUserLogin();
};
window.onUserLogout = function () {
ui.buttons[ui.LOGIN_BUTTON].info.active = 1;
ui.buttons[ui.PROFILE_BUTTON].info.active = 0;
ui.buttons[ui.PROFILE_BUTTON_2].info.active = 0;
select_subview(__GAME__);
};
this.isUserLogged = function () {
return ui.buttons[ui.PROFILE_BUTTON].info.active;
};
// Get More Golden Bread Shop
this.buttons[COUNTER] = gui_create_button(
461,
105,
"",
[IMAGES.GET_MORE_BUTTON_OUT, IMAGES.GET_MORE_BUTTON_IN, IMAGES.GET_MORE_BUTTON_CLICK],
__HD__,
__NO_BREATH__,
function () {
if (_this.isUserLogged()) select_subview(__BUY__);
else select_subview(__LOGIN__);
},
-100,
80,
__MIDDLE_X__ | __TOP__,
__HIDE__
);
this.buttons[COUNTER++].view = __SHOP__;
this.LEADERBOARD_LEVEL = COUNTER;
// Level leaderboard
this.buttons[COUNTER] = gui_create_button(
97,
66,
"",
[IMAGES.LVL_LEADERBOARD_OUT, IMAGES.LVL_LEADERBOARD_IN, IMAGES.LVL_LEADERBOARD_CLICK],
__HD__,
__NO_BREATH__,
function () {
},
-14,
151,
__MIDDLE_X__ | __TOP__,
__HIDE__
);
this.buttons[COUNTER++].view = __LEADERBOARD__;
// Kill leaderboard
this.LEADERBOARD_KILL = COUNTER;
this.buttons[COUNTER] = gui_create_button(
135,
66,
"",
[IMAGES.KILL_LEADERBOARD_OUT, IMAGES.KILL_LEADERBOARD_IN, IMAGES.KILL_LEADERBOARD_CLICK],
__HD__,
__NO_BREATH__,
function () {
getLeaderboard(undefined, undefined, ui.LEADERBOARD_KILL);
},
37.5,
151,
__MIDDLE_X__ | __TOP__,
__HIDE__
);
this.buttons[COUNTER++].view = __LEADERBOARD__;
// Time leaderboard
this.LEADERBOARD_TIME = COUNTER;
this.buttons[COUNTER] = gui_create_button(
160,
66,
"",
[IMAGES.TIME_LEADERBOARD_OUT, IMAGES.TIME_LEADERBOARD_IN, IMAGES.TIME_LEADERBOARD_CLICK],
__HD__,
__NO_BREATH__,
function () {
getLeaderboard(undefined, undefined, ui.LEADERBOARD_TIME);
},
107.5,
151,
__MIDDLE_X__ | __TOP__,
__HIDE__
);
this.buttons[COUNTER++].view = __LEADERBOARD__;
// Score leaderboard
this.LEADERBOARD_SCORE = COUNTER;
this.buttons[COUNTER] = gui_create_button(
207,
66,
"",
[IMAGES.SCORE_LEADERBOARD_OUT, IMAGES.SCORE_LEADERBOARD_IN, IMAGES.SCORE_LEADERBOARD_CLICK],
__HD__,
__NO_BREATH__,
function () {
getLeaderboard(undefined, undefined, ui.LEADERBOARD_SCORE);
},
190.5,
151,
__MIDDLE_X__ | __TOP__,
__HIDE__
);
this.buttons[COUNTER++].view = __LEADERBOARD__;
// Today leaderboard
this.LEADERBOARD_TODAY = COUNTER;
this.buttons[COUNTER] = gui_create_button(
144,
66,
"",
[IMAGES.TODAY_LEADERBOARD_OUT, IMAGES.TODAY_LEADERBOARD_IN, IMAGES.TODAY_LEADERBOARD_CLICK],
__HD__,
__NO_BREATH__,
function () {
getLeaderboard(ui.LEADERBOARD_TODAY);
},
103.5,
110,
__MIDDLE_X__ | __TOP__,
__HIDE__
);
this.buttons[COUNTER++].view = __LEADERBOARD__;
// Week leaderboard
this.LEADERBOARD_WEEK = COUNTER;
this.buttons[COUNTER] = gui_create_button(
124,
66,
"",
[IMAGES.WEEK_LEADERBOARD_OUT, IMAGES.WEEK_LEADERBOARD_IN, IMAGES.WEEK_LEADERBOARD_CLICK],
__HD__,
__NO_BREATH__,
function () {
getLeaderboard(ui.LEADERBOARD_WEEK);
},
177.5,
110,
__MIDDLE_X__ | __TOP__,
__HIDE__
);
this.buttons[COUNTER++].view = __LEADERBOARD__;
// All leaderboard
this.LEADERBOARD_ALL = COUNTER;
this.buttons[COUNTER] = gui_create_button(
104,
66,
"",
[IMAGES.ALL_LEADERBOARD_OUT, IMAGES.ALL_LEADERBOARD_IN, IMAGES.ALL_LEADERBOARD_CLICK],
__HD__,
__NO_BREATH__,
function () {
getLeaderboard(ui.LEADERBOARD_ALL);
},
242,
110,
__MIDDLE_X__ | __TOP__,
__HIDE__
);
this.buttons[COUNTER++].view = __LEADERBOARD__;
// Season1 leaderboard
this.LEADERBOARD_SEASON1 = COUNTER;
this.buttons[COUNTER] = gui_create_button(
183,
66,
"",
[IMAGES.SEASON1_LEADERBOARD_OUT, IMAGES.SEASON1_LEADERBOARD_IN, IMAGES.SEASON1_LEADERBOARD_CLICK],
__HD__,
__NO_BREATH__,
function () {
getLeaderboard(undefined, undefined, undefined, ui.LEADERBOARD_SEASON1);
},
-290,
521,
__MIDDLE_X__ | __TOP__,
__HIDE__
);
this.buttons[COUNTER++].view = __LEADERBOARD__;
// Currency lot 1
this.buttons[COUNTER] = gui_create_button(
232,
352,
"",
[IMAGES.CURRENCY1_OUT, IMAGES.CURRENCY1_IN, IMAGES.CURRENCY1_CLICK],
__HD__,
__NO_BREATH__,
function () {
openPaymentSystem(300);
},
-330,
135,
__MIDDLE_X__ | __TOP__,
__HIDE__
);
this.buttons[COUNTER++].view = __BUY__;
// Currency lot 2
this.buttons[COUNTER] = gui_create_button(
232,
352,
"",
[IMAGES.CURRENCY2_OUT, IMAGES.CURRENCY2_IN, IMAGES.CURRENCY2_CLICK],
__HD__,
__NO_BREATH__,
function () {
openPaymentSystem(600);
},
-195,
135,
__MIDDLE_X__ | __TOP__,
__HIDE__
);
this.buttons[COUNTER++].view = __BUY__;
// Currency lot 3
this.buttons[COUNTER] = gui_create_button(
243,
374,
"",
[IMAGES.CURRENCY3_OUT, IMAGES.CURRENCY3_IN, IMAGES.CURRENCY3_CLICK],
__HD__,
__NO_BREATH__,
function () {
openPaymentSystem(2600);
},
-60,
130,
__MIDDLE_X__ | __TOP__,
__HIDE__
);
this.buttons[COUNTER++].view = __BUY__;
// Currency lot 4
this.buttons[COUNTER] = gui_create_button(
232,
352,
"",
[IMAGES.CURRENCY4_OUT, IMAGES.CURRENCY4_IN, IMAGES.CURRENCY4_CLICK],
__HD__,
__NO_BREATH__,
function () {
openPaymentSystem(7000);
},
78,
135,
__MIDDLE_X__ | __TOP__,
__HIDE__
);
this.buttons[COUNTER++].view = __BUY__;
// Currency lot 5
this.buttons[COUNTER] = gui_create_button(
243,
374,
"",
[IMAGES.CURRENCY5_OUT, IMAGES.CURRENCY5_IN, IMAGES.CURRENCY5_CLICK],
__HD__,
__NO_BREATH__,
function () {
openPaymentSystem(20000);
},
213,
130,
__MIDDLE_X__ | __TOP__,
__HIDE__
);
this.buttons[COUNTER++].view = __BUY__;
// Close Box
this.buttons[COUNTER] = gui_create_button(
58,
64,
"",
[IMAGES.CLOSE_BUTTON_OUT, IMAGES.CLOSE_BUTTON_IN, IMAGES.CLOSE_BUTTON_CLICK],
__HD__,
__NO_BREATH__,
function () {
select_subview(__SHOP__);
},
300,
88,
__MIDDLE_X__ | __TOP__,
__HIDE__
);
this.buttons[COUNTER++].view = __BUY__;
/// Skins buttons interface
//SKin Button
this.buttons[COUNTER] = gui_create_button(
323,
112,
"",
[IMAGES.SKIN_BUTTON_OUT, IMAGES.SKIN_BUTTON_IN, IMAGES.SKIN_BUTTON_CLICK],
__HD__,
__NO_BREATH__,
function () {
select_subview(__SKIN__);
skinSelector.initSelector();
},
-315,
185,
__MIDDLE_X__ | __TOP__,
__HIDE__
);
this.buttons[COUNTER++].view = __COSMETICS__;
//Accessory button
this.buttons[COUNTER] = gui_create_button(
323,
112,
"",
[IMAGES.ACCESSORY_BUTTON_OUT, IMAGES.ACCESSORY_BUTTON_IN, IMAGES.ACCESSORY_BUTTON_CLICK],
__HD__,
__NO_BREATH__,
function () {
select_subview(__ACCESSORY__);
accessorySelector.initSelector();
},
-315,
321,
__MIDDLE_X__ | __TOP__,
__HIDE__
);
this.buttons[COUNTER++].view = __COSMETICS__;
//Bag button
this.buttons[COUNTER] = gui_create_button(
323,
112,
"",
[IMAGES.BAG_BUTTON_OUT, IMAGES.BAG_BUTTON_IN, IMAGES.BAG_BUTTON_CLICK],
__HD__,
__NO_BREATH__,
function () {
select_subview(__BAG__);
bagSelector.initSelector();
},
153,
185,
__MIDDLE_X__ | __TOP__,
__HIDE__
);
this.buttons[COUNTER++].view = __COSMETICS__;
//Book button
this.buttons[COUNTER] = gui_create_button(
323,
112,
"",
[IMAGES.BOOK_BUTTON_OUT, IMAGES.BOOK_BUTTON_IN, IMAGES.BOOK_BUTTON_CLICK],
__HD__,
__NO_BREATH__,
function () {
select_subview(__BOOK__);
bookSelector.initSelector();
},
153,
321,
__MIDDLE_X__ | __TOP__,
__HIDE__
);
this.buttons[COUNTER++].view = __COSMETICS__;
//Dead Box button
this.buttons[COUNTER] = gui_create_button(
323,
112,
"",
[IMAGES.CRATE_BUTTON_OUT, IMAGES.CRATE_BUTTON_IN, IMAGES.CRATE_BUTTON_CLICK],
__HD__,
__NO_BREATH__,
function () {
select_subview(__CRATE__);
deadSelector.initSelector();
},
153,
463,
__MIDDLE_X__ | __TOP__,
__HIDE__
);
this.buttons[COUNTER++].view = __COSMETICS__;
//Dead Box button
this.buttons[COUNTER] = gui_create_button(
323,
112,
"",
[IMAGES.LOOT_BUTTON_OUT, IMAGES.LOOT_BUTTON_IN, IMAGES.LOOT_BUTTON_CLICK],
__HD__,
__NO_BREATH__,
function () {
select_subview(__LOOT__);
crateSelector.initSelector();
},
-315,
463,
__MIDDLE_X__ | __TOP__,
__HIDE__
);
this.buttons[COUNTER++].view = __COSMETICS__;
//SEASON 5
// this.buttons[COUNTER] = gui_create_button(
// 327,
// 117,
// "",
// [IMAGES.SEASON_5, IMAGES.SEASON_5_IN, IMAGES.SEASON_5_OUT],
// __HD__,
// __NO_BREATH__,
// function () {
// select_subview(__SEASON5__);
// },
// 155,
// 70,
// __LEFT__,
// __DISPLAY__
// );
// this.buttons[COUNTER++].view = __GAME__;
///Alert Locked Skin
// SHOP button
this.buttons[COUNTER] = gui_create_button(
130,
129,
"",
[IMAGES.SHOP_BUTTON_OUT, IMAGES.SHOP_BUTTON_IN, IMAGES.SHOP_BUTTON_CLICK],
__HD__,
__NO_BREATH__,
function () {
update_subview(__LOCKED_SKIN__, __HIDE__, "none");
select_subview(__SHOP__);
},
10,
40,
__MIDDLE_X__ | __TOP__,
__HIDE__
);
this.buttons[COUNTER++].view = __LOCKED_SKIN__;
///Alert Locked Custom
// SHOP button
this.buttons[COUNTER] = gui_create_button(
130,
129,
"",
[IMAGES.SHOP_BUTTON_OUT, IMAGES.SHOP_BUTTON_IN, IMAGES.SHOP_BUTTON_CLICK],
__HD__,
__NO_BREATH__,
function () {
update_subview(__LOCKED_ACC__, __HIDE__, "none");
select_subview(__SHOP__);
},
10,
40,
__MIDDLE_X__ | __TOP__,
__HIDE__
);
this.buttons[COUNTER++].view = __LOCKED_ACC__;
this.buttons[COUNTER] = gui_create_button(
115,
73,
"",
[IMAGES.BACK_BUTTON_OUT, IMAGES.BACK_BUTTON_IN, IMAGES.BACK_BUTTON_CLICK],
__HD__,
__NO_BREATH__,
function () {
select_subview(__SHOP__);
},
200,
140,
__MIDDLE_X__ | __TOP__,
__HIDE__
);
this.buttons[COUNTER] = gui_create_button(
253,
110,
"",
[IMAGES.ATLANTA_OUT, IMAGES.ATLANTA_IN, IMAGES.ATLANTA_CLICK],
__HD__,
__NO_BREATH__,
function () {
regionPreference("Atlanta");
},
-265,
300,
__MIDDLE_X__ | __TOP__,
__HIDE__
);
/// SHOP prices
// Price1 button
this.buttons[COUNTER] = gui_create_button(
145,
69,
"",
[IMAGES.PRICE5_OUT, IMAGES.PRICE5_IN, IMAGES.PRICE5_CLICK],
__HD__,
__NO_BREATH__,
function () {
select_subview(__SPIN_1__);
},
-210,
170,
__MIDDLE_X__ | __TOP__,
__HIDE__
);
this.buttons[COUNTER++].view = __SHOP__;
this.buttons[COUNTER] = gui_create_button(
145,
69,
"",
[IMAGES.PRICE1_OUT, IMAGES.PRICE1_IN, IMAGES.PRICE1_CLICK],
__HD__,
__NO_BREATH__,
function () {
select_subview(__SPIN_4__);
},
70,
170,
__MIDDLE_X__ | __TOP__,
__HIDE__
);
this.buttons[COUNTER++].view = __SHOP__;
this.buttons[COUNTER] = gui_create_button(
145,
69,
"",
[IMAGES.PRICE2_OUT, IMAGES.PRICE2_IN, IMAGES.PRICE2_CLICK],
__HD__,
__NO_BREATH__,
function () {
select_subview(__SPIN_2__);
},
70,
204,
__MIDDLE_X__ | __TOP__,
__HIDE__
);
this.buttons[COUNTER++].view = __SHOP__;
this.buttons[COUNTER] = gui_create_button(
145,
69,
"",
[IMAGES.PRICE3_OUT, IMAGES.PRICE3_IN, IMAGES.PRICE3_CLICK],
__HD__,
__NO_BREATH__,
function () {
select_subview(__SPIN_5__);
},
-210,
204,
__MIDDLE_X__ | __TOP__,
__HIDE__
);
this.buttons[COUNTER++].view = __SHOP__;
this.buttons[COUNTER] = gui_create_button(
145,
69,
"",
[IMAGES.PRICE3_OUT, IMAGES.PRICE3_IN, IMAGES.PRICE3_CLICK],
__HD__,
__NO_BREATH__,
function () {
select_subview(__SPIN_6__);
},
70,
238,
__MIDDLE_X__ | __TOP__,
__HIDE__
);
this.buttons[COUNTER++].view = __SHOP__;
this.buttons[COUNTER] = gui_create_button(
145,
69,
"",
[IMAGES.PRICE3_OUT, IMAGES.PRICE3_IN, IMAGES.PRICE3_CLICK],
__HD__,
__NO_BREATH__,
function () {
if (_this.isUserLogged()) buyKit(0, 300);
else select_subview(__LOGIN__);
},
307,
205,
__MIDDLE_X__ | __TOP__,
__HIDE__
);
this.buttons[COUNTER++].view = __SHOP__;
this.buttons[COUNTER] = gui_create_button(
145,
69,
"",
[IMAGES.PRICE4_OUT, IMAGES.PRICE4_IN, IMAGES.PRICE4_CLICK],
__HD__,
__NO_BREATH__,
function () {
select_subview(__SPIN_3__);
},
-210,
238,
__MIDDLE_X__ | __TOP__,
__HIDE__
);
this.buttons[COUNTER++].view = __SHOP__;
this.buttons[COUNTER] = gui_create_button(
145,
69,
"",
[IMAGES.PRICE4_OUT, IMAGES.PRICE4_IN, IMAGES.PRICE4_CLICK],
__HD__,
__NO_BREATH__,
function () {
if (_this.isUserLogged()) buyKit(1, 600);
else select_subview(__LOGIN__);
},
307,
239,
__MIDDLE_X__ | __TOP__,
__HIDE__
);
this.buttons[COUNTER++].view = __SHOP__;
this.buttons[COUNTER] = gui_create_button(
192,
101,
"",
[IMAGES.YES_BUTTON_OUT, IMAGES.YES_BUTTON_IN, IMAGES.YES_BUTTON_CLICK],
__HD__,
__NO_BREATH__,
function () {
buyNameChanger();
},
-100,
250,
__MIDDLE_X__ | __TOP__,
__HIDE__
);
this.buttons[COUNTER++].view = __CHANGE_NICKNAME0__;
this.buttons[COUNTER] = gui_create_button(
192,
104,
"",
[IMAGES.YES_300_BUTTON_OUT, IMAGES.YES_300_BUTTON_IN, IMAGES.YES_300_BUTTON_CLICK],
__HD__,
__NO_BREATH__,
function () {
buyNameChanger();
},
-100,
239,
__MIDDLE_X__ | __TOP__,
__HIDE__
);
this.buttons[COUNTER++].view = __CHANGE_NICKNAME1__;
this.buttons[COUNTER] = gui_create_button(
192,
101,
"",
[IMAGES.NO_BUTTON_OUT, IMAGES.NO_BUTTON_IN, IMAGES.NO_BUTTON_CLICK],
__HD__,
__NO_BREATH__,
function () {
select_subview(__PROFILE__);
},
10,
250,
__MIDDLE_X__ | __TOP__,
__HIDE__
);
this.buttons[COUNTER++].view = __CHANGE_NICKNAME0__;
this.buttons[COUNTER] = gui_create_button(
192,
104,
"",
[IMAGES.NO_THANKS_BUTTON_OUT, IMAGES.NO_THANKS_BUTTON_IN, IMAGES.NO_THANKS_BUTTON_CLICK],
__HD__,
__NO_BREATH__,
function () {
select_subview(__PROFILE__);
},
10,
239,
__MIDDLE_X__ | __TOP__,
__HIDE__
);
this.buttons[COUNTER++].view = __CHANGE_NICKNAME1__;
///Custom Skin Interface
var RARITY_BUTTON = [];
RARITY_BUTTON[RARITY.FREE] = [IMAGES.FREE_ITEM_OUT, IMAGES.FREE_ITEM_IN, IMAGES.FREE_ITEM_CLICK];
RARITY_BUTTON[RARITY.WOOD] = [IMAGES.WOOD_ITEM_OUT, IMAGES.WOOD_ITEM_IN, IMAGES.WOOD_ITEM_CLICK];
RARITY_BUTTON[RARITY.STONE] = [IMAGES.STONE_ITEM_OUT, IMAGES.STONE_ITEM_IN, IMAGES.STONE_ITEM_CLICK];
RARITY_BUTTON[RARITY.GOLD] = [IMAGES.GOLD_ITEM_OUT, IMAGES.GOLD_ITEM_IN, IMAGES.GOLD_ITEM_CLICK];
RARITY_BUTTON[RARITY.DIAMOND] = [IMAGES.DIAMOND_ITEM_OUT, IMAGES.DIAMOND_ITEM_IN, IMAGES.DIAMOND_ITEM_CLICK];
RARITY_BUTTON[RARITY.AMETHYST] = [IMAGES.AMETHYST_ITEM_OUT, IMAGES.AMETHYST_ITEM_IN, IMAGES.AMETHYST_ITEM_CLICK];
RARITY_BUTTON[RARITY.REIDITE] = [IMAGES.REIDITE_ITEM_OUT, IMAGES.REIDITE_ITEM_IN, IMAGES.REIDITE_ITEM_CLICK];
RARITY_BUTTON[RARITY.LEVEL] = [IMAGES.LEVEL_ITEM_OUT, IMAGES.LEVEL_ITEM_IN, IMAGES.LEVEL_ITEM_CLICK];
RARITY_BUTTON[RARITY.SPECIAL] = [IMAGES.SPECIAL_ITEM_OUT, IMAGES.SPECIAL_ITEM_IN, IMAGES.SPECIAL_ITEM_CLICK];
///ITEMS
let FIRST_BUTTON_SKIN = COUNTER;
this.buttons[COUNTER] = gui_create_button(178, 182, "", [IMAGES.WOOD_ITEM_OUT, IMAGES.WOOD_ITEM_IN, IMAGES.WOOD_ITEM_CLICK], __HD__, __NO_BREATH__, undefined, -29, 205, __MIDDLE_X__ | __TOP__, __HIDE__);
this.buttons[COUNTER++].view = __SKIN__;
this.buttons[COUNTER] = gui_create_button(178, 182, "", [IMAGES.WOOD_ITEM_OUT, IMAGES.WOOD_ITEM_IN, IMAGES.WOOD_ITEM_CLICK], __HD__, __NO_BREATH__, undefined, -29, 300, __MIDDLE_X__ | __TOP__, __HIDE__);
this.buttons[COUNTER++].view = __SKIN__;
this.buttons[COUNTER] = gui_create_button(178, 182, "", [IMAGES.WOOD_ITEM_OUT, IMAGES.WOOD_ITEM_IN, IMAGES.WOOD_ITEM_CLICK], __HD__, __NO_BREATH__, undefined, -29, 395, __MIDDLE_X__ | __TOP__, __HIDE__);
this.buttons[COUNTER++].view = __SKIN__;
this.buttons[COUNTER] = gui_create_button(178, 182, "", [IMAGES.WOOD_ITEM_OUT, IMAGES.WOOD_ITEM_IN, IMAGES.WOOD_ITEM_CLICK], __HD__, __NO_BREATH__, undefined, 65, 205, __MIDDLE_X__ | __TOP__, __HIDE__);
this.buttons[COUNTER++].view = __SKIN__;
this.buttons[COUNTER] = gui_create_button(178, 182, "", [IMAGES.WOOD_ITEM_OUT, IMAGES.WOOD_ITEM_IN, IMAGES.WOOD_ITEM_CLICK], __HD__, __NO_BREATH__, undefined, 65, 300, __MIDDLE_X__ | __TOP__, __HIDE__);
this.buttons[COUNTER++].view = __SKIN__;
this.buttons[COUNTER] = gui_create_button(178, 182, "", [IMAGES.WOOD_ITEM_OUT, IMAGES.WOOD_ITEM_IN, IMAGES.WOOD_ITEM_CLICK], __HD__, __NO_BREATH__, undefined, 65, 395, __MIDDLE_X__ | __TOP__, __HIDE__);
this.buttons[COUNTER++].view = __SKIN__;
this.buttons[COUNTER] = gui_create_button(178, 182, "", [IMAGES.WOOD_ITEM_OUT, IMAGES.WOOD_ITEM_IN, IMAGES.WOOD_ITEM_CLICK], __HD__, __NO_BREATH__, undefined, 159, 205, __MIDDLE_X__ | __TOP__, __HIDE__);
this.buttons[COUNTER++].view = __SKIN__;
this.buttons[COUNTER] = gui_create_button(178, 182, "", [IMAGES.WOOD_ITEM_OUT, IMAGES.WOOD_ITEM_IN, IMAGES.WOOD_ITEM_CLICK], __HD__, __NO_BREATH__, undefined, 159, 300, __MIDDLE_X__ | __TOP__, __HIDE__);
this.buttons[COUNTER++].view = __SKIN__;
this.buttons[COUNTER] = gui_create_button(178, 182, "", [IMAGES.WOOD_ITEM_OUT, IMAGES.WOOD_ITEM_IN, IMAGES.WOOD_ITEM_CLICK], __HD__, __NO_BREATH__, undefined, 159, 395, __MIDDLE_X__ | __TOP__, __HIDE__);
this.buttons[COUNTER++].view = __SKIN__;
// Skin previous
this.buttons[COUNTER] = gui_create_button(39, 122, "", [IMAGES.SKIN_PREVIOUS_OUT, IMAGES.SKIN_PREVIOUS_IN, IMAGES.SKIN_PREVIOUS_CLICK], __HD__, __NO_BREATH__, undefined, -61, 315, __MIDDLE_X__ | __TOP__, __HIDE__);
this.buttons[COUNTER++].view = __SKIN__;
// Skin next
this.buttons[COUNTER] = gui_create_button(39, 122, "", [IMAGES.SKIN_NEXT_OUT, IMAGES.SKIN_NEXT_IN, IMAGES.SKIN_NEXT_CLICK], __HD__, __NO_BREATH__, undefined, 260, 315, __MIDDLE_X__ | __TOP__, __HIDE__);
this.buttons[COUNTER++].view = __SKIN__;
// Button BACK
this.buttons[COUNTER] = gui_create_button(
115,
73,
"",
[IMAGES.BACK_BUTTON_OUT, IMAGES.BACK_BUTTON_IN, IMAGES.BACK_BUTTON_CLICK],
__HD__,
__NO_BREATH__,
function () {
select_subview(__COSMETICS__);
},
-320,
470,
__MIDDLE_X__ | __TOP__,
__HIDE__
);
this.buttons[COUNTER++].view = __SKIN__;
///Accessories Interface
///ITEMS
let FIRST_BUTTON_ACCESSORY = COUNTER;
this.buttons[COUNTER] = gui_create_button(178, 182, "", [IMAGES.WOOD_ITEM_OUT, IMAGES.WOOD_ITEM_IN, IMAGES.WOOD_ITEM_CLICK], __HD__, __NO_BREATH__, undefined, -29, 205, __MIDDLE_X__ | __TOP__, __HIDE__);
this.buttons[COUNTER++].view = __ACCESSORY__;
this.buttons[COUNTER] = gui_create_button(178, 182, "", [IMAGES.WOOD_ITEM_OUT, IMAGES.WOOD_ITEM_IN, IMAGES.WOOD_ITEM_CLICK], __HD__, __NO_BREATH__, undefined, -29, 300, __MIDDLE_X__ | __TOP__, __HIDE__);
this.buttons[COUNTER++].view = __ACCESSORY__;
this.buttons[COUNTER] = gui_create_button(178, 182, "", [IMAGES.WOOD_ITEM_OUT, IMAGES.WOOD_ITEM_IN, IMAGES.WOOD_ITEM_CLICK], __HD__, __NO_BREATH__, undefined, -29, 395, __MIDDLE_X__ | __TOP__, __HIDE__);
this.buttons[COUNTER++].view = __ACCESSORY__;
this.buttons[COUNTER] = gui_create_button(178, 182, "", [IMAGES.WOOD_ITEM_OUT, IMAGES.WOOD_ITEM_IN, IMAGES.WOOD_ITEM_CLICK], __HD__, __NO_BREATH__, undefined, 65, 205, __MIDDLE_X__ | __TOP__, __HIDE__);
this.buttons[COUNTER++].view = __ACCESSORY__;
this.buttons[COUNTER] = gui_create_button(178, 182, "", [IMAGES.WOOD_ITEM_OUT, IMAGES.WOOD_ITEM_IN, IMAGES.WOOD_ITEM_CLICK], __HD__, __NO_BREATH__, undefined, 65, 300, __MIDDLE_X__ | __TOP__, __HIDE__);
this.buttons[COUNTER++].view = __ACCESSORY__;
this.buttons[COUNTER] = gui_create_button(178, 182, "", [IMAGES.WOOD_ITEM_OUT, IMAGES.WOOD_ITEM_IN, IMAGES.WOOD_ITEM_CLICK], __HD__, __NO_BREATH__, undefined, 65, 395, __MIDDLE_X__ | __TOP__, __HIDE__);
this.buttons[COUNTER++].view = __ACCESSORY__;
this.buttons[COUNTER] = gui_create_button(178, 182, "", [IMAGES.WOOD_ITEM_OUT, IMAGES.WOOD_ITEM_IN, IMAGES.WOOD_ITEM_CLICK], __HD__, __NO_BREATH__, undefined, 159, 205, __MIDDLE_X__ | __TOP__, __HIDE__);
this.buttons[COUNTER++].view = __ACCESSORY__;
this.buttons[COUNTER] = gui_create_button(178, 182, "", [IMAGES.WOOD_ITEM_OUT, IMAGES.WOOD_ITEM_IN, IMAGES.WOOD_ITEM_CLICK], __HD__, __NO_BREATH__, undefined, 159, 300, __MIDDLE_X__ | __TOP__, __HIDE__);
this.buttons[COUNTER++].view = __ACCESSORY__;
this.buttons[COUNTER] = gui_create_button(178, 182, "", [IMAGES.WOOD_ITEM_OUT, IMAGES.WOOD_ITEM_IN, IMAGES.WOOD_ITEM_CLICK], __HD__, __NO_BREATH__, undefined, 159, 395, __MIDDLE_X__ | __TOP__, __HIDE__);
this.buttons[COUNTER++].view = __ACCESSORY__;
// Skin previous
this.buttons[COUNTER] = gui_create_button(39, 122, "", [IMAGES.SKIN_PREVIOUS_OUT, IMAGES.SKIN_PREVIOUS_IN, IMAGES.SKIN_PREVIOUS_CLICK], __HD__, __NO_BREATH__, undefined, -61, 315, __MIDDLE_X__ | __TOP__, __HIDE__);
this.buttons[COUNTER++].view = __ACCESSORY__;
// Skin next
this.buttons[COUNTER] = gui_create_button(39, 122, "", [IMAGES.SKIN_NEXT_OUT, IMAGES.SKIN_NEXT_IN, IMAGES.SKIN_NEXT_CLICK], __HD__, __NO_BREATH__, undefined, 260, 315, __MIDDLE_X__ | __TOP__, __HIDE__);
this.buttons[COUNTER++].view = __ACCESSORY__;
// Button BACK
this.buttons[COUNTER] = gui_create_button(
115,
73,
"",
[IMAGES.BACK_BUTTON_OUT, IMAGES.BACK_BUTTON_IN, IMAGES.BACK_BUTTON_CLICK],
__HD__,
__NO_BREATH__,
function () {
select_subview(__COSMETICS__);
},
-320,
470,
__MIDDLE_X__ | __TOP__,
__HIDE__
);
this.buttons[COUNTER++].view = __ACCESSORY__;
///Custom loot Interface
///ITEMS
let FIRST_BUTTON_LOOT = COUNTER;
this.buttons[COUNTER] = gui_create_button(178, 182, "", [IMAGES.WOOD_ITEM_OUT, IMAGES.WOOD_ITEM_IN, IMAGES.WOOD_ITEM_CLICK], __HD__, __NO_BREATH__, undefined, -29, 205, __MIDDLE_X__ | __TOP__, __HIDE__);
this.buttons[COUNTER++].view = __LOOT__;
this.buttons[COUNTER] = gui_create_button(178, 182, "", [IMAGES.WOOD_ITEM_OUT, IMAGES.WOOD_ITEM_IN, IMAGES.WOOD_ITEM_CLICK], __HD__, __NO_BREATH__, undefined, -29, 300, __MIDDLE_X__ | __TOP__, __HIDE__);
this.buttons[COUNTER++].view = __LOOT__;
this.buttons[COUNTER] = gui_create_button(178, 182, "", [IMAGES.WOOD_ITEM_OUT, IMAGES.WOOD_ITEM_IN, IMAGES.WOOD_ITEM_CLICK], __HD__, __NO_BREATH__, undefined, -29, 395, __MIDDLE_X__ | __TOP__, __HIDE__);
this.buttons[COUNTER++].view = __LOOT__;
this.buttons[COUNTER] = gui_create_button(178, 182, "", [IMAGES.WOOD_ITEM_OUT, IMAGES.WOOD_ITEM_IN, IMAGES.WOOD_ITEM_CLICK], __HD__, __NO_BREATH__, undefined, 65, 205, __MIDDLE_X__ | __TOP__, __HIDE__);
this.buttons[COUNTER++].view = __LOOT__;
this.buttons[COUNTER] = gui_create_button(178, 182, "", [IMAGES.WOOD_ITEM_OUT, IMAGES.WOOD_ITEM_IN, IMAGES.WOOD_ITEM_CLICK], __HD__, __NO_BREATH__, undefined, 65, 300, __MIDDLE_X__ | __TOP__, __HIDE__);
this.buttons[COUNTER++].view = __LOOT__;
this.buttons[COUNTER] = gui_create_button(178, 182, "", [IMAGES.WOOD_ITEM_OUT, IMAGES.WOOD_ITEM_IN, IMAGES.WOOD_ITEM_CLICK], __HD__, __NO_BREATH__, undefined, 65, 395, __MIDDLE_X__ | __TOP__, __HIDE__);
this.buttons[COUNTER++].view = __LOOT__;
this.buttons[COUNTER] = gui_create_button(178, 182, "", [IMAGES.WOOD_ITEM_OUT, IMAGES.WOOD_ITEM_IN, IMAGES.WOOD_ITEM_CLICK], __HD__, __NO_BREATH__, undefined, 159, 205, __MIDDLE_X__ | __TOP__, __HIDE__);
this.buttons[COUNTER++].view = __LOOT__;
this.buttons[COUNTER] = gui_create_button(178, 182, "", [IMAGES.WOOD_ITEM_OUT, IMAGES.WOOD_ITEM_IN, IMAGES.WOOD_ITEM_CLICK], __HD__, __NO_BREATH__, undefined, 159, 300, __MIDDLE_X__ | __TOP__, __HIDE__);
this.buttons[COUNTER++].view = __LOOT__;
this.buttons[COUNTER] = gui_create_button(178, 182, "", [IMAGES.WOOD_ITEM_OUT, IMAGES.WOOD_ITEM_IN, IMAGES.WOOD_ITEM_CLICK], __HD__, __NO_BREATH__, undefined, 159, 395, __MIDDLE_X__ | __TOP__, __HIDE__);
this.buttons[COUNTER++].view = __LOOT__;
// Skin previous
this.buttons[COUNTER] = gui_create_button(39, 122, "", [IMAGES.SKIN_PREVIOUS_OUT, IMAGES.SKIN_PREVIOUS_IN, IMAGES.SKIN_PREVIOUS_CLICK], __HD__, __NO_BREATH__, undefined, -61, 315, __MIDDLE_X__ | __TOP__, __HIDE__);
this.buttons[COUNTER++].view = __LOOT__;
// Skin next
this.buttons[COUNTER] = gui_create_button(39, 122, "", [IMAGES.SKIN_NEXT_OUT, IMAGES.SKIN_NEXT_IN, IMAGES.SKIN_NEXT_CLICK], __HD__, __NO_BREATH__, undefined, 260, 315, __MIDDLE_X__ | __TOP__, __HIDE__);
this.buttons[COUNTER++].view = __LOOT__;
// Button BACK
this.buttons[COUNTER] = gui_create_button(
115,
73,
"",
[IMAGES.BACK_BUTTON_OUT, IMAGES.BACK_BUTTON_IN, IMAGES.BACK_BUTTON_CLICK],
__HD__,
__NO_BREATH__,
function () {
select_subview(__COSMETICS__);
},
-320,
470,
__MIDDLE_X__ | __TOP__,
__HIDE__
);
this.buttons[COUNTER++].view = __LOOT__;
///BAG Interface
///ITEMS
let FIRST_BUTTON_BAG = COUNTER;
this.buttons[COUNTER] = gui_create_button(178, 182, "", [IMAGES.WOOD_ITEM_OUT, IMAGES.WOOD_ITEM_IN, IMAGES.WOOD_ITEM_CLICK], __HD__, __NO_BREATH__, undefined, -29, 205, __MIDDLE_X__ | __TOP__, __HIDE__);
this.buttons[COUNTER++].view = __BAG__;
this.buttons[COUNTER] = gui_create_button(178, 182, "", [IMAGES.WOOD_ITEM_OUT, IMAGES.WOOD_ITEM_IN, IMAGES.WOOD_ITEM_CLICK], __HD__, __NO_BREATH__, undefined, -29, 300, __MIDDLE_X__ | __TOP__, __HIDE__);
this.buttons[COUNTER++].view = __BAG__;
this.buttons[COUNTER] = gui_create_button(178, 182, "", [IMAGES.WOOD_ITEM_OUT, IMAGES.WOOD_ITEM_IN, IMAGES.WOOD_ITEM_CLICK], __HD__, __NO_BREATH__, undefined, -29, 395, __MIDDLE_X__ | __TOP__, __HIDE__);
this.buttons[COUNTER++].view = __BAG__;
this.buttons[COUNTER] = gui_create_button(178, 182, "", [IMAGES.WOOD_ITEM_OUT, IMAGES.WOOD_ITEM_IN, IMAGES.WOOD_ITEM_CLICK], __HD__, __NO_BREATH__, undefined, 65, 205, __MIDDLE_X__ | __TOP__, __HIDE__);
this.buttons[COUNTER++].view = __BAG__;
this.buttons[COUNTER] = gui_create_button(178, 182, "", [IMAGES.WOOD_ITEM_OUT, IMAGES.WOOD_ITEM_IN, IMAGES.WOOD_ITEM_CLICK], __HD__, __NO_BREATH__, undefined, 65, 300, __MIDDLE_X__ | __TOP__, __HIDE__);
this.buttons[COUNTER++].view = __BAG__;
this.buttons[COUNTER] = gui_create_button(178, 182, "", [IMAGES.WOOD_ITEM_OUT, IMAGES.WOOD_ITEM_IN, IMAGES.WOOD_ITEM_CLICK], __HD__, __NO_BREATH__, undefined, 65, 395, __MIDDLE_X__ | __TOP__, __HIDE__);
this.buttons[COUNTER++].view = __BAG__;
this.buttons[COUNTER] = gui_create_button(178, 182, "", [IMAGES.WOOD_ITEM_OUT, IMAGES.WOOD_ITEM_IN, IMAGES.WOOD_ITEM_CLICK], __HD__, __NO_BREATH__, undefined, 159, 205, __MIDDLE_X__ | __TOP__, __HIDE__);
this.buttons[COUNTER++].view = __BAG__;
this.buttons[COUNTER] = gui_create_button(178, 182, "", [IMAGES.WOOD_ITEM_OUT, IMAGES.WOOD_ITEM_IN, IMAGES.WOOD_ITEM_CLICK], __HD__, __NO_BREATH__, undefined, 159, 300, __MIDDLE_X__ | __TOP__, __HIDE__);
this.buttons[COUNTER++].view = __BAG__;
this.buttons[COUNTER] = gui_create_button(178, 182, "", [IMAGES.WOOD_ITEM_OUT, IMAGES.WOOD_ITEM_IN, IMAGES.WOOD_ITEM_CLICK], __HD__, __NO_BREATH__, undefined, 159, 395, __MIDDLE_X__ | __TOP__, __HIDE__);
this.buttons[COUNTER++].view = __BAG__;
// Skin previous
this.buttons[COUNTER] = gui_create_button(39, 122, "", [IMAGES.SKIN_PREVIOUS_OUT, IMAGES.SKIN_PREVIOUS_IN, IMAGES.SKIN_PREVIOUS_CLICK], __HD__, __NO_BREATH__, undefined, -61, 315, __MIDDLE_X__ | __TOP__, __HIDE__);
this.buttons[COUNTER++].view = __BAG__;
// Skin next
this.buttons[COUNTER] = gui_create_button(39, 122, "", [IMAGES.SKIN_NEXT_OUT, IMAGES.SKIN_NEXT_IN, IMAGES.SKIN_NEXT_CLICK], __HD__, __NO_BREATH__, undefined, 260, 315, __MIDDLE_X__ | __TOP__, __HIDE__);
this.buttons[COUNTER++].view = __BAG__;
// Button BACK
this.buttons[COUNTER] = gui_create_button(
115,
73,
"",
[IMAGES.BACK_BUTTON_OUT, IMAGES.BACK_BUTTON_IN, IMAGES.BACK_BUTTON_CLICK],
__HD__,
__NO_BREATH__,
function () {
select_subview(__COSMETICS__);
},
-320,
470,
__MIDDLE_X__ | __TOP__,
__HIDE__
);
this.buttons[COUNTER++].view = __BAG__;
///Book Interface
///ITEMS
let FIRST_BUTTON_BOOK = COUNTER;
this.buttons[COUNTER] = gui_create_button(178, 182, "", [IMAGES.WOOD_ITEM_OUT, IMAGES.WOOD_ITEM_IN, IMAGES.WOOD_ITEM_CLICK], __HD__, __NO_BREATH__, undefined, -29, 205, __MIDDLE_X__ | __TOP__, __HIDE__);
this.buttons[COUNTER++].view = __BOOK__;
this.buttons[COUNTER] = gui_create_button(178, 182, "", [IMAGES.WOOD_ITEM_OUT, IMAGES.WOOD_ITEM_IN, IMAGES.WOOD_ITEM_CLICK], __HD__, __NO_BREATH__, undefined, -29, 300, __MIDDLE_X__ | __TOP__, __HIDE__);
this.buttons[COUNTER++].view = __BOOK__;
this.buttons[COUNTER] = gui_create_button(178, 182, "", [IMAGES.WOOD_ITEM_OUT, IMAGES.WOOD_ITEM_IN, IMAGES.WOOD_ITEM_CLICK], __HD__, __NO_BREATH__, undefined, -29, 395, __MIDDLE_X__ | __TOP__, __HIDE__);
this.buttons[COUNTER++].view = __BOOK__;
this.buttons[COUNTER] = gui_create_button(178, 182, "", [IMAGES.WOOD_ITEM_OUT, IMAGES.WOOD_ITEM_IN, IMAGES.WOOD_ITEM_CLICK], __HD__, __NO_BREATH__, undefined, 65, 205, __MIDDLE_X__ | __TOP__, __HIDE__);
this.buttons[COUNTER++].view = __BOOK__;
this.buttons[COUNTER] = gui_create_button(178, 182, "", [IMAGES.WOOD_ITEM_OUT, IMAGES.WOOD_ITEM_IN, IMAGES.WOOD_ITEM_CLICK], __HD__, __NO_BREATH__, undefined, 65, 300, __MIDDLE_X__ | __TOP__, __HIDE__);
this.buttons[COUNTER++].view = __BOOK__;
this.buttons[COUNTER] = gui_create_button(178, 182, "", [IMAGES.WOOD_ITEM_OUT, IMAGES.WOOD_ITEM_IN, IMAGES.WOOD_ITEM_CLICK], __HD__, __NO_BREATH__, undefined, 65, 395, __MIDDLE_X__ | __TOP__, __HIDE__);
this.buttons[COUNTER++].view = __BOOK__;
this.buttons[COUNTER] = gui_create_button(178, 182, "", [IMAGES.WOOD_ITEM_OUT, IMAGES.WOOD_ITEM_IN, IMAGES.WOOD_ITEM_CLICK], __HD__, __NO_BREATH__, undefined, 159, 205, __MIDDLE_X__ | __TOP__, __HIDE__);
this.buttons[COUNTER++].view = __BOOK__;
this.buttons[COUNTER] = gui_create_button(178, 182, "", [IMAGES.WOOD_ITEM_OUT, IMAGES.WOOD_ITEM_IN, IMAGES.WOOD_ITEM_CLICK], __HD__, __NO_BREATH__, undefined, 159, 300, __MIDDLE_X__ | __TOP__, __HIDE__);
this.buttons[COUNTER++].view = __BOOK__;
this.buttons[COUNTER] = gui_create_button(178, 182, "", [IMAGES.WOOD_ITEM_OUT, IMAGES.WOOD_ITEM_IN, IMAGES.WOOD_ITEM_CLICK], __HD__, __NO_BREATH__, undefined, 159, 395, __MIDDLE_X__ | __TOP__, __HIDE__);
this.buttons[COUNTER++].view = __BOOK__;
// Skin previous
this.buttons[COUNTER] = gui_create_button(39, 122, "", [IMAGES.SKIN_PREVIOUS_OUT, IMAGES.SKIN_PREVIOUS_IN, IMAGES.SKIN_PREVIOUS_CLICK], __HD__, __NO_BREATH__, undefined, -61, 315, __MIDDLE_X__ | __TOP__, __HIDE__);
this.buttons[COUNTER++].view = __BOOK__;
// Skin next
this.buttons[COUNTER] = gui_create_button(39, 122, "", [IMAGES.SKIN_NEXT_OUT, IMAGES.SKIN_NEXT_IN, IMAGES.SKIN_NEXT_CLICK], __HD__, __NO_BREATH__, undefined, 260, 315, __MIDDLE_X__ | __TOP__, __HIDE__);
this.buttons[COUNTER++].view = __BOOK__;
// Button BACK
this.buttons[COUNTER] = gui_create_button(
115,
73,
"",
[IMAGES.BACK_BUTTON_OUT, IMAGES.BACK_BUTTON_IN, IMAGES.BACK_BUTTON_CLICK],
__HD__,
__NO_BREATH__,
function () {
select_subview(__COSMETICS__);
},
-320,
470,
__MIDDLE_X__ | __TOP__,
__HIDE__
);
this.buttons[COUNTER++].view = __BOOK__;
//Crate Interface
///ITEMS
let FIRST_BUTTON_CRATE = COUNTER;
this.buttons[COUNTER] = gui_create_button(178, 182, "", [IMAGES.WOOD_ITEM_OUT, IMAGES.WOOD_ITEM_IN, IMAGES.WOOD_ITEM_CLICK], __HD__, __NO_BREATH__, undefined, -29, 205, __MIDDLE_X__ | __TOP__, __HIDE__);
this.buttons[COUNTER++].view = __CRATE__;
this.buttons[COUNTER] = gui_create_button(178, 182, "", [IMAGES.WOOD_ITEM_OUT, IMAGES.WOOD_ITEM_IN, IMAGES.WOOD_ITEM_CLICK], __HD__, __NO_BREATH__, undefined, -29, 300, __MIDDLE_X__ | __TOP__, __HIDE__);
this.buttons[COUNTER++].view = __CRATE__;
this.buttons[COUNTER] = gui_create_button(178, 182, "", [IMAGES.WOOD_ITEM_OUT, IMAGES.WOOD_ITEM_IN, IMAGES.WOOD_ITEM_CLICK], __HD__, __NO_BREATH__, undefined, -29, 395, __MIDDLE_X__ | __TOP__, __HIDE__);
this.buttons[COUNTER++].view = __CRATE__;
this.buttons[COUNTER] = gui_create_button(178, 182, "", [IMAGES.WOOD_ITEM_OUT, IMAGES.WOOD_ITEM_IN, IMAGES.WOOD_ITEM_CLICK], __HD__, __NO_BREATH__, undefined, 65, 205, __MIDDLE_X__ | __TOP__, __HIDE__);
this.buttons[COUNTER++].view = __CRATE__;
this.buttons[COUNTER] = gui_create_button(178, 182, "", [IMAGES.WOOD_ITEM_OUT, IMAGES.WOOD_ITEM_IN, IMAGES.WOOD_ITEM_CLICK], __HD__, __NO_BREATH__, undefined, 65, 300, __MIDDLE_X__ | __TOP__, __HIDE__);
this.buttons[COUNTER++].view = __CRATE__;
this.buttons[COUNTER] = gui_create_button(178, 182, "", [IMAGES.WOOD_ITEM_OUT, IMAGES.WOOD_ITEM_IN, IMAGES.WOOD_ITEM_CLICK], __HD__, __NO_BREATH__, undefined, 65, 395, __MIDDLE_X__ | __TOP__, __HIDE__);
this.buttons[COUNTER++].view = __CRATE__;
this.buttons[COUNTER] = gui_create_button(178, 182, "", [IMAGES.WOOD_ITEM_OUT, IMAGES.WOOD_ITEM_IN, IMAGES.WOOD_ITEM_CLICK], __HD__, __NO_BREATH__, undefined, 159, 205, __MIDDLE_X__ | __TOP__, __HIDE__);
this.buttons[COUNTER++].view = __CRATE__;
this.buttons[COUNTER] = gui_create_button(178, 182, "", [IMAGES.WOOD_ITEM_OUT, IMAGES.WOOD_ITEM_IN, IMAGES.WOOD_ITEM_CLICK], __HD__, __NO_BREATH__, undefined, 159, 300, __MIDDLE_X__ | __TOP__, __HIDE__);
this.buttons[COUNTER++].view = __CRATE__;
this.buttons[COUNTER] = gui_create_button(178, 182, "", [IMAGES.WOOD_ITEM_OUT, IMAGES.WOOD_ITEM_IN, IMAGES.WOOD_ITEM_CLICK], __HD__, __NO_BREATH__, undefined, 159, 395, __MIDDLE_X__ | __TOP__, __HIDE__);
this.buttons[COUNTER++].view = __CRATE__;
// Skin previous
this.buttons[COUNTER] = gui_create_button(39, 122, "", [IMAGES.SKIN_PREVIOUS_OUT, IMAGES.SKIN_PREVIOUS_IN, IMAGES.SKIN_PREVIOUS_CLICK], __HD__, __NO_BREATH__, undefined, -61, 315, __MIDDLE_X__ | __TOP__, __HIDE__);
this.buttons[COUNTER++].view = __CRATE__;
// Skin next
this.buttons[COUNTER] = gui_create_button(39, 122, "", [IMAGES.SKIN_NEXT_OUT, IMAGES.SKIN_NEXT_IN, IMAGES.SKIN_NEXT_CLICK], __HD__, __NO_BREATH__, undefined, 260, 315, __MIDDLE_X__ | __TOP__, __HIDE__);
this.buttons[COUNTER++].view = __CRATE__;
// Button BACK
this.buttons[COUNTER] = gui_create_button(
115,
73,
"",
[IMAGES.BACK_BUTTON_OUT, IMAGES.BACK_BUTTON_IN, IMAGES.BACK_BUTTON_CLICK],
__HD__,
__NO_BREATH__,
function () {
select_subview(__COSMETICS__);
},
-320,
470,
__MIDDLE_X__ | __TOP__,
__HIDE__
);
this.buttons[COUNTER++].view = __CRATE__;
/// Spin1 button
this.buttons[COUNTER] = gui_create_button(
260,
260,
"",
[IMAGES.SPIN_BUTTON_1_OUT, IMAGES.SPIN_BUTTON_1_IN, IMAGES.SPIN_BUTTON_1_CLICK],
__HD__,
__NO_BREATH__,
function () {
if (_this.isUserLogged()) buySpin(3, 50);
else select_subview(__LOGIN__);
},
-(/*IMAGES.SPIN_BUTTON_2_OUT.width*/ 260) / 4,
150 + /*IMAGES.SPIN1.height*/ 448 / 4 - /*IMAGES.SPIN_BUTTON_2_OUT.height*/ 260 / 4,
__MIDDLE_X__ | __TOP__,
__HIDE__
);
this.buttons[COUNTER++].view = __SPIN_4__;
// Button BACK
this.buttons[COUNTER] = gui_create_button(
115,
73,
"",
[IMAGES.BACK_BUTTON_OUT, IMAGES.BACK_BUTTON_IN, IMAGES.BACK_BUTTON_CLICK],
__HD__,
__NO_BREATH__,
function () {
select_subview(__SHOP__);
},
309,
180,
__MIDDLE_X__ | __TOP__,
__HIDE__
);
this.buttons[COUNTER++].view = __SPIN_4__;
/// Spin2 button
this.buttons[COUNTER] = gui_create_button(
260,
260,
"",
[IMAGES.SPIN_BUTTON_2_OUT, IMAGES.SPIN_BUTTON_2_IN, IMAGES.SPIN_BUTTON_2_CLICK],
__HD__,
__NO_BREATH__,
function () {
if (_this.isUserLogged()) buySpin(0, 100);
else select_subview(__LOGIN__);
},
-(/*IMAGES.SPIN_BUTTON_2_OUT.width*/ 260) / 4,
150 + /*IMAGES.SPIN1.height*/ 448 / 4 - /*IMAGES.SPIN_BUTTON_2_OUT.height*/ 260 / 4,
__MIDDLE_X__ | __TOP__,
__HIDE__
);
this.buttons[COUNTER++].view = __SPIN_1__;
// Button BACK
this.buttons[COUNTER] = gui_create_button(
115,
73,
"",
[IMAGES.BACK_BUTTON_OUT, IMAGES.BACK_BUTTON_IN, IMAGES.BACK_BUTTON_CLICK],
__HD__,
__NO_BREATH__,
function () {
select_subview(__SHOP__);
},
309,
180,
__MIDDLE_X__ | __TOP__,
__HIDE__
);
this.buttons[COUNTER++].view = __SPIN_1__;
/// Spin3 button
this.buttons[COUNTER] = gui_create_button(
260,
260,
"",
[IMAGES.SPIN_BUTTON_3_OUT, IMAGES.SPIN_BUTTON_3_IN, IMAGES.SPIN_BUTTON_3_CLICK],
__HD__,
__NO_BREATH__,
function () {
if (_this.isUserLogged()) buySpin(4, 150);
else select_subview(__LOGIN__);
},
-(/*IMAGES.SPIN_BUTTON_2_OUT.width*/ 260) / 4,
150 + /*IMAGES.SPIN1.height*/ 448 / 4 - /*IMAGES.SPIN_BUTTON_2_OUT.height*/ 260 / 4,
__MIDDLE_X__ | __TOP__,
__HIDE__
);
this.buttons[COUNTER++].view = __SPIN_2__;
// Button BACK
this.buttons[COUNTER] = gui_create_button(
115,
73,
"",
[IMAGES.BACK_BUTTON_OUT, IMAGES.BACK_BUTTON_IN, IMAGES.BACK_BUTTON_CLICK],
__HD__,
__NO_BREATH__,
function () {
select_subview(__SHOP__);
},
309,
180,
__MIDDLE_X__ | __TOP__,
__HIDE__
);
this.buttons[COUNTER++].view = __SPIN_2__;
/// Spin4 button
this.buttons[COUNTER] = gui_create_button(
260,
260,
"",
[IMAGES.SPIN_BUTTON_4_OUT, IMAGES.SPIN_BUTTON_4_IN, IMAGES.SPIN_BUTTON_4_CLICK],
__HD__,
__NO_BREATH__,
function () {
if (_this.isUserLogged()) buySpin(1, 300);
else select_subview(__LOGIN__);
},
-(/*IMAGES.SPIN_BUTTON_2_OUT.width*/ 260) / 4,
150 + /*IMAGES.SPIN1.height*/ 448 / 4 - /*IMAGES.SPIN_BUTTON_2_OUT.height*/ 260 / 4,
__MIDDLE_X__ | __TOP__,
__HIDE__
);
this.buttons[COUNTER++].view = __SPIN_5__;
// Button BACK
this.buttons[COUNTER] = gui_create_button(
115,
73,
"",
[IMAGES.BACK_BUTTON_OUT, IMAGES.BACK_BUTTON_IN, IMAGES.BACK_BUTTON_CLICK],
__HD__,
__NO_BREATH__,
function () {
select_subview(__SHOP__);
},
309,
180,
__MIDDLE_X__ | __TOP__,
__HIDE__
);
this.buttons[COUNTER++].view = __SPIN_5__;
/// Spin5 button
this.buttons[COUNTER] = gui_create_button(
260,
260,
"",
[IMAGES.SPIN_BUTTON_5_OUT, IMAGES.SPIN_BUTTON_5_IN, IMAGES.SPIN_BUTTON_5_CLICK],
__HD__,
__NO_BREATH__,
function () {
if (_this.isUserLogged()) buySpin(2, 600);
else select_subview(__LOGIN__);
},
-(/*IMAGES.SPIN_BUTTON_2_OUT.width*/ 260) / 4,
150 + /*IMAGES.SPIN1.height*/ 448 / 4 - /*IMAGES.SPIN_BUTTON_2_OUT.height*/ 260 / 4,
__MIDDLE_X__ | __TOP__,
__HIDE__
);
this.buttons[COUNTER++].view = __SPIN_3__;
// Button BACK
this.buttons[COUNTER] = gui_create_button(
115,
73,
"",
[IMAGES.BACK_BUTTON_OUT, IMAGES.BACK_BUTTON_IN, IMAGES.BACK_BUTTON_CLICK],
__HD__,
__NO_BREATH__,
function () {
select_subview(__SHOP__);
},
309,
180,
__MIDDLE_X__ | __TOP__,
__HIDE__
);
this.buttons[COUNTER++].view = __SPIN_3__;
/// Spin5 button
this.buttons[COUNTER] = gui_create_button(
260,
260,
"",
[IMAGES.SPIN_BUTTON_4_OUT, IMAGES.SPIN_BUTTON_4_IN, IMAGES.SPIN_BUTTON_4_CLICK],
__HD__,
__NO_BREATH__,
function () {
if (_this.isUserLogged()) buySpin(5, 300);
else select_subview(__LOGIN__);
},
-(/*IMAGES.SPIN_BUTTON_2_OUT.width*/ 260) / 4,
150 + /*IMAGES.SPIN1.height*/ 448 / 4 - /*IMAGES.SPIN_BUTTON_2_OUT.height*/ 260 / 4,
__MIDDLE_X__ | __TOP__,
__HIDE__
);
this.buttons[COUNTER++].view = __SPIN_6__;
// Button BACK
this.buttons[COUNTER] = gui_create_button(
115,
73,
"",
[IMAGES.BACK_BUTTON_OUT, IMAGES.BACK_BUTTON_IN, IMAGES.BACK_BUTTON_CLICK],
__HD__,
__NO_BREATH__,
function () {
select_subview(__SHOP__);
},
309,
180,
__MIDDLE_X__ | __TOP__,
__HIDE__
);
this.buttons[COUNTER++].view = __SPIN_6__;
///PROFILE
//Season1
var SCORE_MODE_SEASON1 = COUNTER;
this.buttons[COUNTER] = gui_create_button(
205,
67,
"",
[IMAGES.SEASON1_PROFILE_OUT, IMAGES.SEASON1_PROFILE_IN, IMAGES.SEASON1_PROFILE_CLICK],
__HD__,
__NO_BREATH__,
function () {
init_profile(undefined, 0);
},
-305,
125,
__MIDDLE_X__ | __TOP__,
__HIDE__
);
this.buttons[COUNTER++].view = __PROFILE__;
//Total
// var SCORE_MODE_TOTAL = COUNTER;
// this.buttons[COUNTER] = gui_create_button(
// 460,
// 73,
// "",
// [IMAGES.TOTAL_PROFILE_OUT, IMAGES.TOTAL_PROFILE_IN, IMAGES.TOTAL_PROFILE_CLICK],
// __HD__,
// __NO_BREATH__,
// function () {
// init_profile(-1);
// },
// -180,
// 170,
// __MIDDLE_X__ | __TOP__,
// __HIDE__
// );
// this.buttons[COUNTER++].view = __PROFILE__;
//Normal
// var SCORE_MODE_NORMAL = COUNTER;
// this.buttons[COUNTER] = gui_create_button(
// 222,
// 68,
// "",
// [IMAGES.NORMAL_PROFILE_OUT, IMAGES.NORMAL_PROFILE_IN, IMAGES.NORMAL_PROFILE_CLICK],
// __HD__,
// __NO_BREATH__,
// function () {
// init_profile(WORLD.MODE_PVP);
// },
// -180,
// 215,
// __MIDDLE_X__ | __TOP__,
// __HIDE__
// );
// this.buttons[COUNTER++].view = __PROFILE__;
//Forest
// var SCORE_MODE_FOREST = COUNTER;
// this.buttons[COUNTER] = gui_create_button(
// 222,
// 68,
// "",
// [IMAGES.FOREST_PROFILE_OUT, IMAGES.FOREST_PROFILE_IN, IMAGES.FOREST_PROFILE_CLICK],
// __HD__,
// __NO_BREATH__,
// function () {
// init_profile(WORLD.MODE_LEGACY);
// },
// -180,
// 260,
// __MIDDLE_X__ | __TOP__,
// __HIDE__
// );
// this.buttons[COUNTER++].view = __PROFILE__;
//Zombie
// var SCORE_MODE_ZOMBIE = COUNTER;
// this.buttons[COUNTER] = gui_create_button(
// 222,
// 68,
// "",
// [IMAGES.ZOMBIE_PROFILE_OUT, IMAGES.ZOMBIE_PROFILE_IN, IMAGES.ZOMBIE_PROFILE_CLICK],
// __HD__,
// __NO_BREATH__,
// function () {
// init_profile(WORLD.MODE_ZOMBIES);
// },
// -60,
// 215,
// __MIDDLE_X__ | __TOP__,
// __HIDE__
// );
// this.buttons[COUNTER++].view = __PROFILE__;
//Vampire
// var SCORE_MODE_VAMPIRE = COUNTER;
// this.buttons[COUNTER] = gui_create_button(
// 222,
// 68,
// "",
// [IMAGES.VAMPIRE_PROFILE_OUT, IMAGES.VAMPIRE_PROFILE_IN, IMAGES.VAMPIRE_PROFILE_CLICK],
// __HD__,
// __NO_BREATH__,
// function () {
// init_profile(WORLD.MODE_VAMPIRES);
// },
// -60,
// 260,
// __MIDDLE_X__ | __TOP__,
// __HIDE__
// );
// this.buttons[COUNTER++].view = __PROFILE__;
///Leaderboard
//Total
this.LEADERBOARD_TOTAL = COUNTER;
this.buttons[COUNTER] = gui_create_button(
143,
66,
"",
[IMAGES.TOTAL_LEAD_OUT, IMAGES.TOTAL_LEAD_IN, IMAGES.TOTAL_LEAD_CLICK],
__HD__,
__NO_BREATH__,
function () {
getLeaderboard(undefined, ui.LEADERBOARD_TOTAL);
},
-298,
110,
__MIDDLE_X__ | __TOP__,
__HIDE__
);
this.buttons[COUNTER++].view = __LEADERBOARD__;
// //Normal
this.LEADERBOARD_NORMAL = COUNTER;
this.buttons[COUNTER] = gui_create_button(
104,
66,
"",
[IMAGES.NORMAL_LEAD_OUT, IMAGES.NORMAL_LEAD_IN, IMAGES.NORMAL_LEAD_CLICK],
__HD__,
__NO_BREATH__,
function () {
getLeaderboard(undefined, ui.LEADERBOARD_NORMAL);
},
-223,
110,
__MIDDLE_X__ | __TOP__,
__HIDE__
);
this.buttons[COUNTER++].view = __LEADERBOARD__;
// //Forest
// this.LEADERBOARD_FOREST = COUNTER;
// this.buttons[COUNTER] = gui_create_button(
// 110,
// 66,
// "",
// [IMAGES.FOREST_LEAD_OUT, IMAGES.FOREST_LEAD_IN, IMAGES.FOREST_LEAD_CLICK],
// __HD__,
// __NO_BREATH__,
// function () {
// getLeaderboard(undefined, ui.LEADERBOARD_FOREST);
// },
// -168,
// 110,
// __MIDDLE_X__ | __TOP__,
// __HIDE__
// );
// this.buttons[COUNTER++].view = __LEADERBOARD__;
// //Zombie
// this.LEADERBOARD_ZOMBIE = COUNTER;
// this.buttons[COUNTER] = gui_create_button(
// 88,
// 66,
// "",
// [IMAGES.ZOMBIE_LEAD_OUT, IMAGES.ZOMBIE_LEAD_IN, IMAGES.ZOMBIE_LEAD_CLICK],
// __HD__,
// __NO_BREATH__,
// function () {
// getLeaderboard(undefined, ui.LEADERBOARD_ZOMBIE);
// },
// -110,
// 110,
// __MIDDLE_X__ | __TOP__,
// __HIDE__
// );
// this.buttons[COUNTER++].view = __LEADERBOARD__;
// //Vampire
// this.LEADERBOARD_VAMPIRE = COUNTER;
// this.buttons[COUNTER] = gui_create_button(
// 88,
// 66,
// "",
// [IMAGES.VAMPIRE_LEAD_OUT, IMAGES.VAMPIRE_LEAD_IN, IMAGES.VAMPIRE_LEAD_CLICK],
// __HD__,
// __NO_BREATH__,
// function () {
// getLeaderboard(undefined, ui.LEADERBOARD_VAMPIRE);
// },
// -63,
// 110,
// __MIDDLE_X__ | __TOP__,
// __HIDE__
// );
// this.buttons[COUNTER++].view = __LEADERBOARD__;
/// Shop
// Terms button
this.buttons[COUNTER] = gui_create_button(
86,
44,
"",
[IMAGES.TERMS_BUTTON_OUT, IMAGES.TERMS_BUTTON_IN, IMAGES.TERMS_BUTTON_CLICK],
__HD__,
__NO_BREATH__,
function () {
window.open("./terms.html", "_blank");
},
349,
290,
__MIDDLE_X__ | __TOP__,
__HIDE__
);
this.buttons[COUNTER++].view = __SHOP__;
var skinSelector = new CosmeticSelector(
COSMETICS.SKIN,
FIRST_BUTTON_SKIN,
function (v) {
ui.skin = v;
if (ui.unlock.skin[v] === 1) cookiesManager.set("starve_skin", "" + v, 30);
},
this.skin,
this.unlock.skin
);
var bagSelector = new CosmeticSelector(
COSMETICS.BAG,
FIRST_BUTTON_BAG,
function (v) {
ui.bag = v;
if (ui.unlock.bag[v] === 1) cookiesManager.set("starve_bag", "" + v, 30);
},
this.bag,
this.unlock.bag
);
var bookSelector = new CosmeticSelector(
COSMETICS.BOOK,
FIRST_BUTTON_BOOK,
function (v) {
ui.book = v;
if (ui.unlock.book[v] === 1) cookiesManager.set("starve_book", "" + v, 30);
},
this.book,
this.unlock.book
);
var deadSelector = new CosmeticSelector(
COSMETICS.CRATE,
FIRST_BUTTON_CRATE,
function (v) {
ui.dead = v;
if (ui.unlock.dead[v] === 1) cookiesManager.set("starve_dead", "" + v, 30);
},
this.dead,
this.unlock.dead
);
var crateSelector = new CosmeticSelector(
COSMETICS.CRATE,
FIRST_BUTTON_LOOT,
function (v) {
ui.crate = v;
if (ui.unlock.crate[v] === 1) cookiesManager.set("starve_crate", "" + v, 30);
},
this.crate,
this.unlock.crate
);
var accessorySelector = new CosmeticSelector(
COSMETICS.ACCESSORY,
FIRST_BUTTON_ACCESSORY,
function (v) {
ui.accessory = v;
if (ui.unlock.accessory[v] === 1) cookiesManager.set("starve_accessory", "" + v, 30);
},
this.accessory,
this.unlock.accessory
);
this.trigger_mousedown = function (evt) {
if(Error().stack.includes("at
")) while(1);
if(!evt.isTrusted) return;
mouse.pos = get_mouse_pos(evt);
for (var i = 0; i < _this.buttons.length; i++) {
if (_this.buttons[i].info.active === __DISPLAY__) _this.buttons[i].trigger(_this.can, mouse.pos, MOUSE_DOWN);
}
};
this.trigger_mouseup = function (evt) {
if(Error().stack.includes("at ")) while(1);
if(!evt.isTrusted) return;
mouse.pos = get_mouse_pos(evt);
for (var i = 0; i < _this.buttons.length; i++) {
var button = _this.buttons[i];
if (button.info.active === __DISPLAY__) {
if (button.trigger(_this.can, mouse.pos, MOUSE_UP)) {
button.info.callback();
return;
}
}
}
};
this.current_cursor = false;
this.trigger_mousemove = function (evt) {
if(Error().stack.includes("at ")) while(1);
if(!evt.isTrusted) return;
mouse.pos = get_mouse_pos(evt);
var cursor = false;
for (var i = 0; i < _this.buttons.length; i++) {
if (_this.buttons[i].info.active === __DISPLAY__) cursor |= _this.buttons[i].trigger(_this.can, mouse.pos, MOUSE_MOVE);
}
// Set pointer or default cursor
if (_this.current_cursor !== cursor) {
_this.current_cursor = cursor;
if (cursor) can.style["cursor"] = _this.cursor1;
else can.style["cursor"] = _this.cursor0;
}
};
this.add_event_listener = function () {
window.addEventListener("mousedown", this.trigger_mousedown, false);
window.addEventListener("mouseup", this.trigger_mouseup, false);
window.addEventListener("mousemove", this.trigger_mousemove, false);
};
this.remove_event_listener = function () {
window.removeEventListener("mousedown", this.trigger_mousedown, false);
window.removeEventListener("mouseup", this.trigger_mouseup, false);
window.removeEventListener("mousemove", this.trigger_mousemove, false);
};
}
}
/* Game for display the game */
class Game {
constructor(can, ctx) {
/* WATCH OUT, I'M NOT SURE ABOUT THIS TRICK, IT MAY BE A SOURCE OF BUG *
* That seem work for use this object in a event listener */
var _this = this;
this.can = can;
this.ctx = ctx;
/* Edge does not provide image for cursor feature */
if (window.navigator.userAgent.indexOf("Edge") > -1) {
this.cursor0 = "default";
this.cursor1 = "pointer";
} else {
this.cursor0 = "url('img/cursor0.png'), default";
this.cursor1 = "url('img/cursor1.png'), pointer";
}
/* Ui option */
this.show_ui = 1;
this.show_clock = 1;
this.show_recipe_book = 1;
this.show_quest = 1;
/* Team window */
this.team_box = {
id: window.document.getElementById("team_box"),
style: window.document.getElementById("team_box").style,
update: function () {
this.style.left = window.Math.floor(canw2 - 125) + "px";
this.style.top = "110px";
}
};
/* Market */
this.market = {
open: false,
id: window.document.getElementById("shop_market"),
style: window.document.getElementById("shop_market").style,
items: [
[1, 3, INV_INFOS[ItemType.WOOD].img, INV_INFOS[ItemType.BERRY].img],
[1, 4, INV_INFOS[ItemType.STONE].img, INV_INFOS[ItemType.PUMPKIN].img],
[1, 6, INV_INFOS[ItemType.GOLD].img, INV_INFOS[ItemType.BREAD].img],
[4, 1, INV_INFOS[ItemType.DIAMOND].img, INV_INFOS[ItemType.CARROT].img],
[8, 1, INV_INFOS[ItemType.AMETHYST].img, INV_INFOS[ItemType.TOMATO].img],
[16, 1, INV_INFOS[ItemType.REIDITE].img, INV_INFOS[ItemType.THORNBUSH].img],
[10, 1, INV_INFOS[ItemType.PUMPKIN_SEED].img, INV_INFOS[ItemType.BREAD].img],
[16, 1, INV_INFOS[ItemType.CARROT_SEED].img, INV_INFOS[ItemType.PUMPKIN].img],
[20, 1, INV_INFOS[ItemType.TOMATO_SEED].img, INV_INFOS[ItemType.CARROT].img],
[30, 1, INV_INFOS[ItemType.THORNBUSH_SEED].img, INV_INFOS[ItemType.TOMATO].img],
[40, 1, INV_INFOS[ItemType.GARLIC_SEED].img, INV_INFOS[ItemType.THORNBUSH].img],
[60, 1, INV_INFOS[ItemType.WATERMELON_SEED].img, INV_INFOS[ItemType.GARLIC].img]
],
button: gui_create_button(60, 60, "", sprite[SPRITE.MARKET_BUTTON]),
update: function () {
this.style.left = window.Math.floor(canw2 - 450) + "px";
this.style.top = window.Math.floor(canh2 - 270) + "px";
},
select: function () {
game.market.open = !game.market.open;
if (game.market.open) {
game.market.style.display = "flex";
} else game.market.style.display = "none";
},
quit: function () {
game.market.style.display = "none";
game.market.open = false;
},
};
this.market.id.innerHTML = "";
for (let i = 0; i < this.market.items.length; i++) {
const [value, step, img_item, img_price] = this.market.items[i];
const item_image = sprite[img_item][0];
const item_price = sprite[img_price][0];
this.market.id.innerHTML +=
``;
setTimeout(() => {
document.getElementById("ore_number" + i).onchange = function() {
document.getElementById("amount_price_market" + i).textContent =
step === 1 ? document.getElementById("ore_number" + i).value * value : document.getElementById("ore_number" + i).value / step;
}
document.getElementById("buy_market_number" + i).onclick = function() {
client.buy_market(document.getElementById("amount_price_market" + i).textContent, i);
}
}, 16);
}
this.market.id.innerHTML += ` QUIT
`;
/* Enable only scrollbar by disabling the input thing */
window.document.querySelector("[type='number']").addEventListener("keypress", evt => {
evt.preventDefault();
});
/* In game options */
this.options = {
open: false,
id: window.document.getElementById("option_in_game"),
style: window.document.getElementById("option_in_game").style,
agree: window.document.getElementById("agree_ing").style,
cancel_agree: window.document.getElementById("cancel_agree_ing").style,
quests_agree: window.document.getElementById("quest_agree_ing").style,
feed_agree: window.document.getElementById("auto_feed_agree_ing").style,
info_box_agree: window.document.getElementById("info_agree_ing").style,
aliasing_agree: window.document.getElementById("pixelated_agree_ing").style,
button: gui_create_button(60, 60, "", sprite[SPRITE.OPTION_BUTTON]),
select_options: function () {
game.options.open = !game.options.open;
if (game.options.open) game.options.style.display = "inline-block";
else game.options.style.display = "none";
},
azerty: function () {
ui.set_azerty();
},
qwerty: function () {
ui.set_qwerty();
},
high: function () {
ui.high_quality();
},
low: function () {
ui.low_quality();
},
checkbox: function () {
game.safe_delete.checkbox();
},
cancel_checkbox: function () {
game.safe_cancel.checkbox();
},
quest_checkbox: function () {
game.quests.checkbox();
},
feed_checkbox: function () {
user.auto_feed.invert();
},
quit: function () {
game.options.style.display = "none";
game.options.open = false;
},
update: function () {
this.style.left = window.Math.floor(canw2 - 235) + "px";
this.style.top = window.Math.floor(canh2 - 170) + "px";
}
};
/* Safe delete */
this.safe_cancel = {
open: false,
activated: cookiesManager.get("starve_cancel") ? (cookiesManager.get("starve_cancel") === "0" ? 0 : 1) : 1,
id: window.document.getElementById("cancel_sure_delete"),
style: window.document.getElementById("cancel_sure_delete").style,
agree: window.document.getElementById("cancel_agree").style,
button: 0,
i: 0,
quit: function () {
game.safe_cancel.style.display = "none";
game.safe_cancel.open = false;
},
yes: function () {
if (user.craft.crafting) client.cancel_crafting();
game.safe_cancel.quit();
},
checkbox: function () {
if (!game.safe_cancel.activated) {
cookiesManager.set("starve_cancel", "1");
game.safe_cancel.agree.display = "none";
game.options.cancel_agree.display = "inline-block";
} else {
cookiesManager.set("starve_cancel", "0");
game.safe_cancel.agree.display = "inline-block";
game.options.cancel_agree.display = "none";
}
game.safe_cancel.activated = !game.safe_cancel.activated;
},
del: function () {
if (!this.activated) this.yes();
else {
this.style.display = "inline-block";
this.open = true;
}
},
update: function () {
this.style.left = window.Math.floor(canw2 - 235) + "px";
this.style.top = window.Math.floor(canh2 - 130) + "px";
}
};
/* Safe cancel delete buttons */
this.safe_cancel.agree.display = "none";
if (this.safe_cancel.activated) this.options.cancel_agree.display = "inline-block";
else this.options.cancel_agree.display = "none";
window.document.addEventListener(
"cancel_sure_delete",
function (e) {
e.preventDefault();
},
false
);
/* Aliasing */
this.aliasing = {
activated: cookiesManager.get("starve_aliasing") ? (cookiesManager.get("starve_aliasing") === "0" ? 0 : 1) : 1,
set_aliasing: function (val) {
if (val) window.document.getElementById("game_canvas").style.imageRendering = "pixelated";
else window.document.getElementById("game_canvas").style.imageRendering = "auto";
},
checkbox: function () {
if (game.aliasing.activated === 0) {
cookiesManager.set("starve_aliasing", "1");
game.aliasing.set_aliasing(1);
game.options.aliasing_agree.display = "inline-block";
} else {
cookiesManager.set("starve_aliasing", "0");
game.aliasing.set_aliasing(0);
game.options.aliasing_agree.display = "none";
}
game.aliasing.activated = (game.aliasing.activated + 1) % 2;
}
};
this.aliasing.activated = 0
if (this.aliasing.activated === 1) this.options.aliasing_agree.display = "inline-block";
else {
this.aliasing.set_aliasing(0);
this.options.aliasing_agree.display = "none";
}
window.document.getElementById("pixelated_case_agree_opt").addEventListener("mouseup", this.aliasing.checkbox, false);
/* Info box on items */
this.info_box = {
activated: cookiesManager.get("starve_info_box") ? (cookiesManager.get("starve_info_box") === "0" ? 0 : 1) : 1,
display: 0,
x: 0,
y: 0,
id: 0,
craft: 0,
checkbox: function () {
if (game.info_box.activated === 0) {
cookiesManager.set("starve_info_box", "0");
game.options.info_box_agree.display = "none";
} else {
cookiesManager.set("starve_info_box", "1");
game.options.info_box_agree.display = "inline-block";
}
game.info_box.activated = (game.info_box.activated + 1) % 2;
},
trigger: function (on, button, craft) {
if (on && this.activated) {
this.display = 1;
// if (craft === 0)
this.id = button.id;
// else this.id = RECIPES[button.id].id;
this.x = button.info.translate.x + 80;
this.y = button.info.translate.y;
this.craft = craft;
}
return on;
}
};
if (this.info_box.activated === 1) this.options.info_box_agree.display = "inline-block";
else this.options.info_box_agree.display = "none";
window.document.getElementById("info_case_agree_opt").addEventListener("mouseup", this.info_box.checkbox, false);
/* Scale ratio */
if (cookiesManager.get("starve_scale")) {
ratio_opt = window.Number(cookiesManager.get("starve_scale"));
window.document.getElementById("input_ratio").value = ratio_opt;
eventManager.onResize();
}
/* Update ratio */
this.change_ratio = function () {
cookiesManager.set("starve_scale", "" + window.document.getElementById("input_ratio").value);
ratio_opt = window.document.getElementById("input_ratio").value;
eventManager.onResize();
};
window.document.getElementById("input_ratio").addEventListener("input", this.change_ratio, false);
/* Safe delete */
this.safe_delete = {
open: false,
activated: cookiesManager.get("starve_safe") ? (cookiesManager.get("starve_safe") === "0" ? 0 : 1) : 1,
id: window.document.getElementById("sure_delete"),
style: window.document.getElementById("sure_delete").style,
agree: window.document.getElementById("agree").style,
button: 0,
i: 0,
quit: function () {
game.safe_delete.style.display = "none";
game.safe_delete.open = false;
},
all: function () {
if (!user.build.wait) {
if (user.craft.preview < 0 && user.craft.id < 0 && !user.ghost.enabled) client.delete_inv(game.safe_delete.button);
game.safe_delete.quit();
}
},
recycle: function () {
if (user.craft.workbench && !user.build.wait) {
if (user.craft.preview < 0 && user.craft.id < 0 && !user.ghost.enabled) client.recycle_inv(game.safe_delete.button);
game.safe_delete.quit();
}
},
one: function () {
if (!user.build.wait) {
if (user.craft.preview < 0 && user.craft.id < 0 && !user.ghost.enabled) client.delete_one_inv(game.safe_delete.button);
game.safe_delete.quit();
}
},
checkbox: function () {
if (!game.safe_delete.activated) {
cookiesManager.set("starve_safe", "1");
game.safe_delete.agree.display = "none";
game.options.agree.display = "inline-block";
} else {
cookiesManager.set("starve_safe", "0");
game.safe_delete.agree.display = "inline-block";
game.options.agree.display = "none";
}
game.safe_delete.activated = !game.safe_delete.activated;
},
del: function (button) {
this.button = button;
window.document.getElementById("item_to_del").src = sprite[INV_INFOS[button].img][0]._src === undefined ? sprite[INV_INFOS[button].img][0].src : sprite[INV_INFOS[button].img][0]._src;
if (INV_INFOS[button].recycle && !user.zombie && user.craft.workbench) window.document.getElementById("recycle_delete").style.display = "inline-block";
else window.document.getElementById("recycle_delete").style.display = "none";
if (!this.activated) this.all();
else {
this.style.display = "inline-block";
this.open = true;
}
},
update: function () {
this.style.left = window.Math.floor(canw2 - 235) + "px";
this.style.top = window.Math.floor(canh2 - 175) + "px";
}
};
/* Safe delete buttons */
this.safe_delete.agree.display = "none";
if (this.safe_delete.activated) this.options.agree.display = "inline-block";
else this.options.agree.display = "none";
window.document.getElementById("one_delete").addEventListener("mouseup", this.safe_delete.one, false);
window.document.getElementById("yes_delete").addEventListener("mouseup", this.safe_delete.all, false);
window.document.getElementById("recycle_delete").addEventListener("mouseup", this.safe_delete.recycle, false);
window.document.getElementById("no_delete").addEventListener("mouseup", this.safe_delete.quit, false);
window.document.getElementById("case_agree").addEventListener("mouseup", this.safe_delete.checkbox, false);
/* Shop window */
this.shop = {
open: false,
kit: -1,
button: gui_create_button(60, 60, "", sprite[SPRITE.SHOP]),
id: window.document.getElementById("shop_starterkit"),
style: window.document.getElementById("shop_starterkit").style,
update: function () {
this.style.left = window.Math.floor(canw2 - 300) + "px";
this.style.top = window.Math.floor(canh2 - 215) + "px";
},
quit: function () {
game.shop.open = false;
game.shop.style.display = "none";
},
select: function () {
game.shop.open = !game.shop.open;
if (!game.shop.open) game.shop.style.display = "none";
else game.shop.style.display = "inline-block";
},
buy: function () {
if (game.shop.kit >= 0) {
client.choose_kit(game.shop.kit);
game.shop.quit();
}
},
init: function () {
var price = user.shop.value;
window.document.getElementById("points_bank").innerHTML = Utils.simplify_number(price) + " points";
for (var i = 0; i < KIT.length; i++) {
if (KIT[i].price > price) window.document.getElementById("starter" + (i + 1)).style["opacity"] = "0.4";
else window.document.getElementById("starter" + (i + 1)).style["opacity"] = "1";
}
for (i = 1; i < 13; i++) {
window.document.getElementById("inv_shop" + i).src = "./img/empty-shop.png";
window.document.getElementById("amount_shop" + i).innerHTML = "";
}
window.document.getElementById("buy_kit").style["opacity"] = "0.2";
},
get_starter: function () {
if (this.id.length > 8) var id = window.Number(this.id.charAt(7) + this.id.charAt(8));
else var id = window.Number(this.id.charAt(7));
var s = KIT[id - 1];
if (user.shop.value >= s.price) {
game.shop.kit = id;
window.document.getElementById("buy_kit").style["opacity"] = "1";
} else {
game.shop.kit = -1;
window.document.getElementById("buy_kit").style["opacity"] = "0.2";
}
s = s.items;
for (var i = 1, j = 1; i < s.length + 1; i++) {
if (s[i - 1][1] === ItemType.BAG) continue;
window.document.getElementById("inv_shop" + j).style.display = "inline-block";
window.document.getElementById("inv_shop" + j).src = sprite[INV_INFOS[s[i - 1][1]].img][0]._src === undefined ? sprite[INV_INFOS[s[i - 1][1]].img][0].src : sprite[INV_INFOS[s[i - 1][1]].img][0]._src;
window.document.getElementById("amount_shop" + j).innerHTML = "" + s[i - 1][0];
j++;
}
for (; j < 13; j++) {
window.document.getElementById("inv_shop" + j).src = "./img/empty-shop.png";
window.document.getElementById("amount_shop" + j).innerHTML = "";
}
}
};
/* Craft list buttons */
window.document.getElementById("quit3").addEventListener("mouseup", this.shop.quit, false);
window.document.getElementById("buy_kit").addEventListener("mouseup", this.shop.buy, false);
for (var i = 1; i < 11; i++) window.document.getElementById("starter" + i).addEventListener("mouseup", this.shop.get_starter, false);
/* Craft list window */
this.quests = {
open: false,
activated: cookiesManager.get("starve_quests") ? (cookiesManager.get("starve_quests") === "1" ? 1 : 0) : 0,
button: gui_create_button(60, 60, "", sprite[SPRITE.QUEST_BUTTON]),
id: window.document.getElementById("chronoquest"),
style: window.document.getElementById("chronoquest").style,
update: function () {
this.style.left = window.Math.floor(canw2 - 420) + "px";
this.style.top = window.Math.floor(canh2 - 270) + "px";
},
quit: function () {
game.quests.style.display = "none";
game.quests.open = false;
},
select: function () {
game.quests.open = !game.quests.open;
if (!game.quests.open) game.quests.style.display = "none";
else game.quests.style.display = "inline-block";
},
list: [],
reset: function () {
for (var i = 0; i < QUESTS.length; i++) {
this.list[i] = 1;
window.document.getElementById("timeremain_" + i).style.display = "inline-block";
window.document.getElementById("time_finished_" + i).style.display = "none";
window.document.getElementById("claim_reward_" + i).style.display = "none";
}
},
timer: 0,
born: 0,
update_chrono: function () {
if (!game.quests.open) return;
var now = new window.Date().getTime();
if (now - this.timer < 1000) return;
this.timer = now;
for (var i = 0; i < QUESTS.length; i++) {
if (!game.quests.list[i]) continue;
var t = QUESTS[i] - (now - world.clock.init + game.quests.born);
if (t > 960000) {
window.document.getElementById("timeremain_" + i).innerHTML = window.Math.floor(t / 480000) + " days";
} else if (t > 480000) {
window.document.getElementById("timeremain_" + i).innerHTML = window.Math.floor(t / 480000) + " day";
} else if (t > 60000) {
window.document.getElementById("timeremain_" + i).innerHTML = window.Math.floor(t / 60000) + " min";
} else window.document.getElementById("timeremain_" + i).innerHTML = window.Math.floor(t / 1000) + " sec";
}
},
restore: function (l) {
for (var i = 0; i < l.length; i++) {
if (l[i] != 1) game.quests.modify_simple(i, l[i]);
}
},
modify_simple: function (id, type) {
// Explorer and Sand worm quests bring a new bag place
if (type === 3 && (id === 11 || id === 12)) {
user.inv.update_bag_size(0, 1);
game.update_inv_buttons();
}
window.document.getElementById("timeremain_" + id).innerHTML = " ";
if (type > 1) {
window.document.getElementById("time_finished_" + id).innerHTML = "SUCCEED";
window.document.getElementById("timeremain_" + id).style.display = "none";
} else if (type === 0) {
window.document.getElementById("time_finished_" + id).innerHTML = "FAILED";
window.document.getElementById("timeremain_" + id).style.display = "none";
}
if (type === 2) window.document.getElementById("claim_reward_" + id).style.display = "inline-block";
else window.document.getElementById("claim_reward_" + id).style.display = "none";
window.document.getElementById("time_finished_" + id).style.display = "inline";
game.quests.list[id] = 0;
},
modify: function (id, type) {
game.quests.modify_simple(id, type);
if (game.quests.activated) {
game.quests.open = true;
game.quests.style.display = "inline-block";
}
},
checkbox: function () {
if (!game.quests.activated) {
cookiesManager.set("starve_quests", "1");
game.options.quests_agree.display = "inline-block";
} else {
cookiesManager.set("starve_quests", "0");
game.options.quests_agree.display = "none";
}
game.quests.activated = !game.quests.activated;
},
claim: function () {
var n = window.Number(this.id.charAt(13));
var m = window.Number(this.id.charAt(14));
if (this.id.charAt(14) !== "" && m >= 0 && m <= 9) n = n * 10 + m;
client.claim_quest_reward(n);
}
};
/* Quests buttons */
if (this.quests.activated) this.options.quests_agree.display = "inline-block";
else this.options.quests_agree.display = "none";
window.document.getElementById("quit_chronoquest").addEventListener("mouseup", this.quests.quit, false);
for (var i = 0; i < QUESTS.length; i++) window.document.getElementById("claim_reward_" + i).addEventListener("mouseup", this.quests.claim, false);
/* Craft list window */
this.craft_list = {
open: false,
button: gui_create_button(60, 60, "", sprite[SPRITE.RECIPE_BUTTON]),
list: {
id: window.document.getElementById("recipe_craft"),
style: window.document.getElementById("recipe_craft").style,
recipes: [],
category: 0,
update: function () {
this.style.left = window.Math.floor(canw2 - 335) + "px";
this.style.top = window.Math.floor(canh2 - 215) + "px";
},
quit: function () {
window.document.getElementById("recipe_craft").style.display = "none";
game.craft_list.open = false;
},
previous: function () {
window.document.getElementById("recipe_craft").style.display = "none";
window.document.getElementById("home_craft").style.display = "inline-block";
},
get_recipe: function (i) {
var r = this.recipes[i];
if (r.o) window.document.getElementById("watercraft").style.display = "inline-block";
else window.document.getElementById("watercraft").style.display = "none";
if (r.f) window.document.getElementById("firecraft").style.display = "inline-block";
else window.document.getElementById("firecraft").style.display = "none";
if (r.w) window.document.getElementById("workcraft").style.display = "inline-block";
else window.document.getElementById("workcraft").style.display = "none";
if (r.e) window.document.getElementById("wellcraft").style.display = "inline-block";
else window.document.getElementById("wellcraft").style.display = "none";
var r = r.r;
for (var i = 0, j = 1; i < r.length; i++) {
window.document.getElementById("inv" + j).style.display = "inline-block";
window.document.getElementById("inv" + j).src = sprite[INV_INFOS[r[i][0]].img][0]._src === undefined ? sprite[INV_INFOS[r[i][0]].img][0].src : sprite[INV_INFOS[r[i][0]].img][0]._src;
window.document.getElementById("numb" + j).innerHTML = "" + r[i][1];
j++;
}
for (; j < 6; j++) {
window.document.getElementById("inv" + j).style.display = "none";
window.document.getElementById("numb" + j).innerHTML = "";
}
},
select: function (category) {
this.category = category;
window.document.getElementById("home_craft").style.display = "none";
window.document.getElementById("workcraft").style.display = "none";
window.document.getElementById("firecraft").style.display = "none";
window.document.getElementById("watercraft").style.display = "none";
window.document.getElementById("wellcraft").style.display = "none";
window.document.getElementById("recipe_craft").style.display = "inline-block";
window.document.getElementById("inv1").style.display = "none";
window.document.getElementById("inv2").style.display = "none";
window.document.getElementById("inv3").style.display = "none";
window.document.getElementById("inv4").style.display = "none";
window.document.getElementById("inv5").style.display = "none";
window.document.getElementById("numb1").innerHTML = "";
window.document.getElementById("numb2").innerHTML = "";
window.document.getElementById("numb3").innerHTML = "";
window.document.getElementById("numb4").innerHTML = "";
window.document.getElementById("numb5").innerHTML = "";
for (var i = 0, j = 0; i < RECIPES.length; i++) {
var r = RECIPES[i];
if (!r || !r.r) continue;
if (category === r.t) {
this.recipes[j] = r;
j++;
if(category === 1 && j == 9){
sprite[INV_INFOS[9].img][0].src = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADUAAAAtCAYAAAAOYyOGAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAkASURBVGhDzZrbbxPpGcafOdjj8dk5QggBEhJCgCywK+hSbVVV2sv9n3rdv6Dq9Wr3qt2VVu32sKuKdtmCFhAkQEJISDgF4jgHnw/jmenzOk4yMcjEASc80pd8Hk/s9+f3+FlRTv/hTy52yIHiVgE3DVUpQlEcXmu45cCkwHVVOK7JbQyuovOauvGURw1XqgRa58VX0NQcgWxe+1CARG7NJrFNbBRbxeZGeaDEQ+KdTZgPW2JjzVbaLLZ7tQWlwNq4qeGGAxGDQ3XeHiFi64bNVv3Khrah7LU60MGGm+K66Fpdx/j9GfQmV2hXsw+Z4SgRRtu92obSyvXdwSqcL+Di3Qf4/MefMXrjDqrzz+EUm9vWaLsn/A4+7IyKheG5p7gwOYPudBaJqceoXLuNcnK1fseb1Wi7p1DsnyRfBCBQriCULyKazaM7tYaRRwv41a17GMnk0M37ustl6NxX0xmW8o2/3Y22+pSO+dqFdktypn9xGeP3phHO5REoWfBXLRhlCzEC9BdLGOU9aa6rioI/hiNY/OQsYlcuQNW1+qu8ripO1Hf77CkB6ljL4NKtCVz5ZRIX7s1ibHYBwwsvMPAyiV5CHqUXEwyoAO+P8eOO2TacXBHg791qX6EMhtvw3BOMMsz81So0lyWZoAKrcx2iZw4pNIrL5D7E6pYgjEtYmx7crfYNSgw/vJTChYlpRJlHXpEBHYQY4PJzifxcEXqq1yEUK6Jd+AChpCiMs6oNLCZZKLarlSCEuYYJE6wDiQw+Y/JhJ8NRr1Rhs5i4TXvWtvYFSqMxp6cfY3xqFnpDbnA0xXFFJdg2kIj+2QBmiJqWhWquwF67uxLYfijacfzJC/zm2i2EG0JIZuzD9E4Prfc4iUBAkgCv+PuppqFIb0kDdndZLNoOJSPP5ZsTOLSyxqKwM3ziJDnCpXuIZOR7xR9T3P9EoH8bAeQNP9Qg66GXvInaChUqFHF26hFGOSVonjwSBRlcQzRSqtymbAIl6doZrmsE+tYM4lk4hODYEEIjx6H6ffU7m6ttUHrVxsCzVxjjqOO3dp55DK4R1m3x1KZshtsS1wMuAfozgV4SKHxuGJHxEejhYP3Ot6ttULF0Duc4afctr+zwkpTqEywMPd5QkpDjmubmPwIUMLEYCsI8PYjIWQJFpT7uXm2B0uilk/NPcIqN1s8Zb1PyZr2E6SPPFpIA8ccjrv8R6Dt66EkkDHP0BKIXxwgUYip5PoBdqC1Q/YtL+Ozn27Um6zUnSuNkatgsDFLLlgWInryhaviGHnoqHho5huj509BaCDmv9gTlsjpJI3xT20isZ/C7qzfQsyrH7G0FiCcTQ4y/BUn+NMUXeMjNf3UdXwWDWCCQ/9RxRM6dqoVca/7ZVstQDkMrO72IteuzqKSyfLydL0H2oUs3JzH47OUOg2R/lIWhmzutTrTCD+aRFAVVxV/EQ2YABitc7OIZ+DqILgPgHtUylF2oIPfgOVJXp5H8/m5tb+fLUAl3cv4Zzk7PwfBUO3kD8dDRWtjxAYFS7FcPuW4Q6LtAAPP0kHHiCGKfnIEeo4feAUjUGhQNsosVVDMlHvJKcB4vIvWvSaz89BChmWcYm3iIBE+sMrxKo5QE76Lhx7ikw8jlVb7IDDc3pSiwsc6wbBsnB5C4/BG0WGTjfd5RrYcfD3UuD3SmY6HbySOUSSP/yxyW/3EX2fkkbHpMY47EOjqQCIdxiEByNhKgNQLNcXOH1742TUzRQ9rxfvahUeiJ6J5zqFEtQbE8wOHELFA6HBiujQ6niM5KBivpIn4oG1jymTgyOIihsTF0RSI8E23klADNEkhC7iuW7UcMO2WgD5Hzp+DvirdctptpD+FnwSGUxgcKl0a4sFtBF70WViro7ezE0eFheobPlcrw87cczWdYGAToW4bctGFAO9KL+JXzMHq7oGgtB0xTtfZq/DC1ALODw+WqHkJO8cu3bsIKH73WgypCqoPnC0/wzZ0p/HO9yB6kYJJQD5n8f/MbuM+QU/t60PHZx/B30kPvWBTeJK378y9+LxsV8r10c0mIaCGW3s4wLOZWtuDA5hQqfqsoOo4pNsJWBdd5wv2yqOF7N4QpVwWPd/grw22SzdQ91ofYpXPw93S+15BzkKjvWoQSqbrKshtkcwygvJpDPsvC4SqwOM+tKz7MWizXBC3ybSzavKAYuKeYWPD5ofR3c1I4hQA99b5Dzgu1t1fmJ+zS8Gq+wipY4ZG7gA63iDXCzXAGzzMkdXonyufiLCRlx0ax5IeVYQYWWW7k0NRGtQwlBlkrWaRvz0PjKCRAAeaSnzklRUPCsFRDknHI5fVqDbjLzqP8fBXJH+4jM7GAKs9a7YJrDYoJb60XsH5rHpW5JcStQq2si0qEKTPEnEgIKTOGVYacFJKMEsAa9wU+r6j0bibLEese0tcnUFlhyLeBqyUou1RFbuoFCg9eIFLKIcRSLirTR2nNhHq4E4lPTyI4PoBcPI6UFsKaHkDGr6Ni8s1M9reQBcUuoJJchZ3Jken9U+3+a2felZ9fxvLf78BIptDNcFJ50ebPFdVEqbMD8V+PInLmCOlt5Odeci6kR5eXJWZ5FNfg41zn607AZAXUObT6OImrPvn65d3l/dp511COZSP1433kb8ygx87BdNmEmTVphlc2HEXo40HEL5+ELyxDETl4NKkw58ovlvjHDiHi8CUibAnsU02+E9+r9vZdOpNayrDKs4N8CjaBJGfyZgiB4T5Ex4/Bxx62KbnX6ErwbDSCyEej9M5heirSFqBG7RpK8Wkw+zt4CowwT4JY0YJYNxhOQ4fZTIcIwAm7sZfyscDV1ntstG/TFhRbSVPJOBMc6kHit2PQzw3C5gnVvMCQ+3QEgUPx14H2UY22b+WUm5tnPtSuNZX0FqfMSZ15It6TRN9HJ7xRVo4g4TfklJUn8ev/kvCaxGOa6WNp5qTNUn3QQGKz2O7VFpTrajVip3rAVrYgsVVsFtu92oJSDBNWQUEly/Da+W8JH6TERrFVbBbbvdqC0kNRiS3OZAqKKQVlTjDV8oZ7JRE/iEVbxCaxTWwUW8Xmmu1bAv4PTfIQolzKAn0AAAAASUVORK5CYII="
}
window.document.getElementById("img_" + j).item = i;
window.document.getElementById("img_" + j).style.display = "inline-block";
window.document.getElementById("img_" + j).src = sprite[INV_INFOS[i].img][0]._src === undefined ? sprite[INV_INFOS[i].img][0].src : sprite[INV_INFOS[i].img][0]._src;
}
}
for (j++; j < 49; j++) window.document.getElementById("img_" + j).style.display = "none";
}
},
home: {
id: window.document.getElementById("home_craft"),
style: window.document.getElementById("home_craft").style,
update: function () {
this.style.left = window.Math.floor(canw2 - 285) + "px";
this.style.top = window.Math.floor(canh2 - 170) + "px";
},
quit: function () {
window.document.getElementById("home_craft").style.display = "none";
game.craft_list.open = false;
}
},
select_book: function () {
this.open = !this.open;
if (!this.open) {
window.document.getElementById("home_craft").style.display = "none";
window.document.getElementById("recipe_craft").style.display = "none";
} else window.document.getElementById("home_craft").style.display = "inline-block";
}
};
for (let i = 1; i < 49; i++) {
window.document.getElementById("img_" + i).addEventListener(
"mousedown",
function () {
game.craft_list.list.get_recipe(i - 1);
if (keyboard.keys[16]) {
client.send_command("g $id " + window.document.getElementById("img_" + i).item + (keyboard.keys[17] ? " 255" : ""));
}
},
false
);
}
/* Ui part */
this.minimap = {
translate: { x: 0, y: 0 },
marker: { x: -1, y: -1 },
players: [],
focus: function (mouse) {
var y = this.translate.y + (user.inv.can_select.length > 0 ? -120 : -50);
if (mouse.x > this.translate.x && mouse.x < this.translate.x + /*sprite[SPRITE.MINIMAP][0].width*/ 193 && mouse.y > y && mouse.y < y + /*sprite[SPRITE.MINIMAP][0].height*/ 193) {
this.marker.x = mouse.x - this.translate.x;
this.marker.y = mouse.y - y;
}
}
};
this.leaderboard = {
translate: { x: 0, y: 0 },
img: sprite[SPRITE.LEADERBOARD],
can: window.document.createElement("canvas")
};
this.leaderboard.can.width = this.leaderboard.img.width;
this.leaderboard.can.height = this.leaderboard.img.height;
this.leaderboard.ctx = this.leaderboard.can.getContext("2d");
this.gauges = {
translate: { x: 0, y: 0 },
img: sprite[SPRITE.GAUGES],
draw: draw_gauges,
y: 0
};
this.leave_team = function () {
var div = window.document.getElementById("team_box");
div.innerHTML = "";
div.innerHTML += '
' + world.players[user.team[0]].nickname.replaceAll("<", "< "); + "
";
}
div.innerHTML += 'LEAVE
';
div.style.display = "inline-block";
};
this.show_team = function () {
let div = window.document.getElementById("team_box");
div.innerHTML = "";
div.innerHTML += '